我已经卸载和安装了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/Frameworks文件夹,所以这为我修复了它

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

第一行为homebrew (brew)创建了一个新的Frameworks文件夹。 第二行为该文件夹提供当前用户权限,这就足够了。

常用命令如下:

Mkdir -创建目录[-p没有错误,如果存在,根据需要创建父目录] chown -更改文件所有者和组[- r对文件和目录进行递归操作] 打印有效的用户id

我有OSX High Sierra

其他回答

github上有一个杀手级脚本,可以修复/usr/local和brew目录上的烫发,使任何“admin”组的成员都可以访问。

https://gist.github.com/jaibeee/9a4ea6aa9d428bc77925

这是一个比选择的答案更好的解决方案,因为如果你把/usr/local/___目录改为$USER,那么你就破坏了那台机器上任何其他homebrew的管理用户。

以下是我发布这篇文章时脚本的核心内容:

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

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

chgrp -R admin /opt/homebrew-cask
chmod -R g+w /opt/homebrew-cask

卸载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

这就解决了我的问题。

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

所有这些建议都可能奏效。在最新版本的brew doctor中,有了更好的建议。

首先-通过在命令行中运行这个命令来修复你可能已经造成的/usr/local混乱:

sudo chown -R root:wheel /usr/local

然后获取路径的所有权,应该专门为这个用户:

sudo chown -R $(whoami) /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/Frameworks /usr/local/lib/pkgconfig /usr/local/share/locale

所有这些信息都是可用的,如果你运行sudo brew update,然后阅读所有的警告和错误,你会遇到…

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

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