I am trying to fix some brew doctor error but now after manually erased some files that brew doctor suggested I get the following error when trying to do a brew update :

error: cannot open .git/FETCH_HEAD: Permission denied

Error: Failed to update tap: homebrew/versions
Already up-to-date.
  • use sudo for the update? – Brad Allred Sep 10 '14 at 16:26
  • 1
    What are the permissions on /usr/local/.git? Sounds like you're perhaps sharing a machine and someone else updated homebrew and, in the course of doing that, took ownership of the /usr/local directory tree. – Ian C. Sep 10 '14 at 16:45
  • No the macbook pro is mine.I am not sharing with anybody else.The permissions of /usr/local/.git are Administrator staff – skiabox Sep 10 '14 at 17:47

I managed to fix this error by fixing the user owner of the /usr/local folder from 504 to Administrator (the user id I am using when I log in to macbook pro terminal).

This was achieved by using this command :

sudo chown -R $USER:admin /usr/local

If you are using OSX High Sierra chown operation is not permitted in /usr/local/ in this case use:

sudo chown -R $(whoami) /usr/local/Homebrew/
sudo chown -R $(whoami):admin /usr/local && sudo chmod -R g+rwx /usr/local

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .