我在/usr/local/下安装了标准的Homebrew。
当我尝试运行:
Larson-2:~ larson$ brew install postgresql
Error: Cannot write to /usr/local/Cellar
当我使用sudo时:
Larson-2:~ larson$ sudo brew install postgresql
Cowardly refusing to `sudo brew install'
我哪里做错了?
我在/usr/local/下安装了标准的Homebrew。
当我尝试运行:
Larson-2:~ larson$ brew install postgresql
Error: Cannot write to /usr/local/Cellar
当我使用sudo时:
Larson-2:~ larson$ sudo brew install postgresql
Cowardly refusing to `sudo brew install'
我哪里做错了?
您似乎对 /usr/local/Cellar
有限制权限。Brew 不喜欢使用 sudo 进行安装,这就是为什么它拒绝安装的原因。
检查权限:
ls -ld /usr/local/Cellar
开放写入权限:
sudo chmod a+w /usr/local/Cellar
出于安全原因,在使用 brew
时请勿使用 sudo
。
您只需要简单设置权限即可。
因此,我建议进一步更改权限为:
sudo chgrp -R admin /usr/local /Library/Caches/Homebrew
sudo chmod -R g+w /usr/local /Library/Caches/Homebrew
然后将特定的组(admin
或staff
)应用于允许使用brew
命令的用户。通过id -Gn
检查您的用户组。
如果有进一步的问题,请运行:brew doctor
查看错误信息。
我会更改群组权限:
$ chgrp -R admin /usr/local/Cellar
$ chmod g+w /usr/local/Cellar
su userWhoInstalledBrew
。sudo chown -R $USER /usr/local
有趣的是,由于磁盘空间不足,我收到了Error: Cannot write to /usr/local/Cellar
错误信息.. :/ (剩余18MB)
jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community@4.2
Warning: You are using OS X 10.15.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Error: Could not create /usr/local/Cellar
Check you have permission to write to /usr/local
jaimes-mbp:SMR jaimemontoya$ sudo mkdir /usr/local/Cellar
Password:
jaimes-mbp:SMR jaimemontoya$ sudo chown $(whoami) /usr/local/Cellar
jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community@4.2
Warning: You are using OS X 10.15.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
==> Installing mongodb-community from mongodb/homebrew-brew
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.3.tgz
###################################################################################### 100.0%
Error: Failed to install plist file
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink .
/usr/local/opt is not writable.
You can try again using:
brew link mongodb-community
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall mongodb/brew/mongodb-community`
==> Caveats
To have launchd start mongodb/brew/mongodb-community at login:
ln -sfv /usr/local/opt/mongodb-community/*.plist ~/Library/LaunchAgents
Then to load mongodb/brew/mongodb-community now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
Or, if you don't want/need launchctl, you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary
/usr/local/Cellar/mongodb-community/4.2.3: 20 files, 304M, built in 110 seconds
jaimes-mbp:SMR jaimemontoya$ sudo mkdir /usr/local/opt
jaimes-mbp:SMR jaimemontoya$ sudo chown $(whoami) /usr/local/opt
jaimes-mbp:SMR jaimemontoya$ brew link mongodb-community
Linking /usr/local/Cellar/mongodb-community/4.2.3... 13 symlinks created
jaimes-mbp:SMR jaimemontoya$
sudo brew install
命令,但是你需要先更改 brew 工具的权限,使其归属于 root 用户。这是一项安全特性。 - mxcl