I was trying to brew update
when I got suddenly a permission error:
/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
I also tried sudo brew update
, but without any luck.
What can I do?
The way that worked for me was to do as @happylookout suggested.
cd /usr/local
git fetch origin
git reset --hard origin/master
However, you may get a permissions error such as:
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'.
To fix this, you need to run the last command above with sudo:
sudo git reset --hard origin/master
Now you should be able to run brew update
without errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With