Brew error: Could not symlink, path is not writable

Brew error: Could not symlink, path is not writable

当我尝试使用 homebrew (brew install aLibrary) 安装库时,出现以下错误:

Could not symlink lib/pkgconfig/aFile
/usr/local/lib/pkgconfig is not writable.

我该怎么办?

有几个问答(1,2,etc.) concerning this brew error, this is an attempt to make a general question as suggested here.

正如解释的那样here by Rick

brew doctor 开始,它会显示您的 brew 设置错误。

您可能会看到类似这样的内容:"Warning: /usr/local/lib/pkgconfig isn't writable."

它会给你这样的建议:"You should probably chown /usr/local/lib/pkgconfig"。

这意味着:sudo chown -R $(whoami) /usr/local/lib/pkgconfig

然后您将需要 link 这些文件:brew link yourLibrary

如果这不起作用,希望 brew doctor 的输出能为您提供足够的信息继续搜索。

我卸载了 brew,重新安装,然后问题就消失了。

使用以下内容。

$ brew doctor

消息将显示错误 links 到 p运行e。如果找到,运行 下一个选项。

$ brew prune

一旦这些被删除,继续link他们agian

$ brew link python

Giant Elk 提出了一个很好的建议,这就是我解决问题的方法,我认为这是最干净的。除非知道后果,否则用户不应更改权限。

  1. 将安装的包(通过 brew)输出到文本文件:

    brew list > brewlist.txt
    
  2. 卸载 brew:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
    
  3. 重新安装 brew:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  4. 重新安装以前的软件包(如果不需要所有软件包,请编辑列表):

    brew install $(< brewlist.txt )
    

您只需在终端上通过 运行 此命令授予您帐户的权限。

sudo chown -R $(whoami) (path)

你的情况: sudo chown -R $(whoami) lib/pkgconfig/aFile /usr/local/lib/pkgconfig