自制安装权限问题

时间:2012-03-21 07:50:33

标签: osx-snow-leopard homebrew package-managers

我在usr / local /

中有一个标准的自制软件安装

当我尝试:

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'

我做错了什么?

7 个答案:

答案 0 :(得分:120)

你以某种方式对/usr/local/Cellar的权限有限。 Brew不喜欢用sudo安装,这就是它拒绝的原因。

检查权限:

ls -ld /usr/local/Cellar

打开它们写作:

sudo chmod a+w /usr/local/Cellar

答案 1 :(得分:9)

使用sudo时不要使用brew(出于安全原因)。

您需要简单设置权限。

所以我会更进一步,将权限更改为:

sudo chgrp -R admin /usr/local /Library/Caches/Homebrew
sudo chmod -R g+w /usr/local /Library/Caches/Homebrew

然后将特定组(adminstaff)应用于应允许使用brew命令的用户。通过以下方式检查用户组:id -Gn)。

如果还有其他问题,请运行:brew doctor以查看错误。

答案 2 :(得分:6)

我更改了群组权限:

$ chgrp -R admin /usr/local/Cellar
$ chmod g+w /usr/local/Cellar

假设您的用户帐户位于群组管理员中。

答案 3 :(得分:1)

如果您的计算机上有多个用户,也会发生这种情况。如果是这样,最好更改用户,因为除了/ usr / local / Cellar之外,其他每种方法都会让你搞乱更多的文件和文件夹

使用su userWhoInstalledBrew

答案 4 :(得分:0)

可以通过将目录的所有者更改为当前用户来解决问题:

sudo chown -R $USER /usr/local

此答案取自:https://github.com/Homebrew/homebrew/issues/17884

答案 5 :(得分:0)

根据他在There is no Cellar file in my usr/local dir for brew的回答中提供的建议chukcha14,我做到了:

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$ 

答案 6 :(得分:0)

很有趣,但是由于缺少磁盘空间,我收到了Error: Cannot write to /usr/local/Cellar消息..:/(剩余18MB)