brew.rb权限被拒绝

时间:2016-03-05 19:29:51

标签: macos homebrew

当我突然遇到权限错误时,我试图brew update

/usr/local/bin/brew: line 28: /usr/local/Library/brew.rb: Permission denied /usr/local/bin/brew: line 28: exec: /usr/local/Library/brew.rb: cannot execute: Undefined error: 0

我也试过sudo brew update,但没有运气。

我该怎么办?

4 个答案:

答案 0 :(得分:8)

对我有用的方法就像@happylookout建议的那样。

cd /usr/local
git fetch origin
git reset --hard origin/master

但是,您可能会收到权限错误,例如:

error: unable to unlink old 'bin/brew' (Permission denied)
error: unable to unlink old 'share/man/man1/brew.1' (Permission denied)
fatal: Could not reset index file to revision 'origin/master'.

要解决此问题,您需要使用sudo运行上面的最后一个命令:

sudo git reset --hard origin/master

现在您应该能够无错误地运行brew update

答案 1 :(得分:4)

刚才遇到同样的问题并通过git更新整个事情来解决它:

self.oneOrZero = ko.observable(0);
self.toggle = function() {
  self.oneOrZero((self.oneOrZero() + 1) % 2);
}

<button data-bind="click : toggle" > Change </button> 

答案 2 :(得分:1)

您可以尝试运行此

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

答案 3 :(得分:0)

我卸载了brew并重新安装了它。解决了这个问题。