我已经卸载和安装了3次Homebrew,因为它似乎永远不允许我安装任何东西,因为它在大多数安装结束时拒绝我的权限。

作为一个例子,我将发布我目前面临的libjpeg下载场景。

我尝试安装libjpeg并获得:

$ brew install libjpeg
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/jpeg-8d.mountain_lion.bottle.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/jpeg-8d.mountain_lion.bottle.1.tar.gz
==> Pouring jpeg-8d.mountain_lion.bottle.1.tar.gz
Warning: Could not link jpeg. Unlinking...
Error: The brew link step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link jpeg'
Error: Permission denied - /usr/local/opt/jpeg

'brew link jpeg'的结果

Error: Permission denied - /usr/local/opt/jpeg

这是我的酿酒医生读的

$ brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
./configure scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run brew link on these:

jpeg

这个许可问题已经使它不可能使用酿造任何东西,我真的很感激任何建议。


当前回答

在我的情况下,/usr/local/框架甚至不存在,所以我做了:

sudo mkdir /usr/local/Frameworks
sudo chown -R $(whoami) /usr/local/Frameworks

然后一切都按照预期进行。

其他回答

如果您没有最新的Homebrew:我在过去通过强制Homebrew以根用户身份运行来“修复”这个问题,这只能通过将Homebrew可执行文件的所有权更改为根用户来实现。在某种程度上,他们删除了这个功能。

我知道他们会给出很多警告,说它不应该以根目录运行,但算了吧,否则它就不能正常工作。

我尝试了这页上的所有方法,最终使用了这个解决方案:

酿造卸载-强制酿造桶;取消$tap_name;酿造更新;啤酒清理;酿造桶清理;

我的情况与OP类似,但是我的问题是由使用酿造桶运行sudo引起的,然后让我的密码不正确。在此之后,我被阻止安装的权限所困扰。

从得票最多的答案命令不工作的我。

它得到输出:

Chown: /usr/{my_username}dmin:非法用户名

这个命令工作正常(组/usr/local已经是admin):

sudo chown -R $USER /usr/local

macOS High Sierra的新命令,因为不可能咀嚼/usr/local:

bash / zsh:

sudo chown -R $(whoami) $(brew --prefix)/*

鱼:

sudo chown -R (whoami) (brew --prefix)/*

参考:不能chown /usr/local在High Sierra

这招对我很管用:

sudo chown -R "$USER":admin /usr/local/Cellar/*
brew cleanup