Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew.rb Permission denied

Tags:

macos

homebrew

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?

like image 211
Tino Avatar asked Dec 11 '22 18:12

Tino


1 Answers

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.

like image 116
biobenkj Avatar answered Jan 24 '23 17:01

biobenkj