2016-03-05 210 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