2016-03-05 209 views
4

我试图brew update,当我突然权限错误:brew.rb权限被拒绝

/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,但没有任何运气。

我该怎么办?

+0

运行酿造医生寻找错误。你永远不需要运行sudo brew下面的chown答案可能会起作用。我的猜测是一些安装程序很糟糕,并且更改了usr/local以归root所有(或者OS X为您升级) – Doon

+0

这实际上是一个运行brew的问题 - “博士医生”会产生相同的错误消息。 – eaj

回答

1

你可以尝试运行此

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

@AndrewMedico:我打电话给bs - [Homebrew项目疑难解答部分建议它](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting) 。如果有什么理由不需要解释,别人应该有不同的理解,那么不要将毫无意义的评论作为建议,并按照文件所建议的做。 –

0

我卸载酿造并重新安装它。修复了这个问题。

4

刚才有同样的问题,并通过经混帐更新整个事情解决了这个问题:

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

这对我有用。 – ksl

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