我已经卸载和安装了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

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


当前回答

对于像我一样降落在这里的人来说,第一选择是,按照这个建议去做:

brew doctor

这是最安全的方法,除此之外,它还建议我:

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

这解决了权限问题。

OP这样做了,但显然没有得到上述建议;你可能会,从这里开始总是更好的,然后再寻找非平凡解如果它没有帮助的话。

其他回答

我在卡特琳娜,我得到了这个错误:

touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied
touch: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/FETCH_HEAD: Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied

我只需要把Homebrew目录翻个遍

sudo chown -R "$USER":admin /usr/local/Homebrew

要解决文件夹上运行的Brew权限的错误

brew prune

这将解决问题,我们不需要咀嚼任何目录。

我可以通过在文件夹上使用chown解决这个问题:

sudo chown -R "$USER":admin /usr/local

此外,你(很可能)必须在/Library/Caches/Homebrew上做同样的事情:

sudo chown -R "$USER":admin /Library/Caches/Homebrew

显然,我之前用sudo改变了我在/usr/local上的文件夹权限, 从这里开始,所有带有brew的安装都被证明是成功的。

这个答案来自gitHub的自制问题跟踪器

对我来说,它在那之后起作用了

酿造的医生

更改权限命令导致另一个错误

chown: /usr/local:不允许操作

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

它得到输出:

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

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

sudo chown -R $USER /usr/local