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

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


当前回答

在我的情况下,我有问题删除和重新安装SaltStack。

在运行:

ls -lah /usr/local/Cellar/salt/

我注意到群组主人是“员工”。(顺便说一下,我运行的是macOS Mojave 10.14.3版。)员工组可能与我的工作场所配置有关,但我真的不知道。无论如何,我保留了这个小组,以防止自己进一步破坏任何东西。

然后我跑了起来:

sudo chown -R "$USER":staff /usr/local/Cellar/salt/

在那之后,我成功地用这个命令删除了它(不是以root用户):

brew uninstall --force salt

其他回答

卸载brew并使用以下命令重新安装,以确保到brew github的链接和本地文件夹的相关权限正常工作:

ruby / usr / bin / e,“美元(卷毛-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

这很有效。我自己没有权限,只是重新安装了Homebrew,它可以工作!

来源:https://gist.github.com/irazasyed/7732946 # gistcomment - 2298740

如果你在OSX High Sierra, /usr/local不能再被咀嚼。你可以使用:

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

我有这个问题… 一个可行的解决方案是更改/usr/local的所有权 将root用户改为当前用户:

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

但实际上这不是一个正确的方法。主要是当您的机器是服务器或多用户时。

我的建议是像上面一样改变所有权,做任何你想用Brew实现的事情。更新,安装…等等),然后将所有权重置回根:

  sudo chown -R root:admin /usr/local

这将解决问题,并保持所有权设置在适当的集合。

对于多用户Mac来说,这对我来说是可行的:

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

我使用了这两个命令并解决了我的问题

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

sudo chown -R $(whoami) /usr/local/etc/bash_completion.d /usr/local/lib/python3.7/site-packages /usr/local/share/aclocal /usr/local/share/locale /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/locks