23
votes

I use Homebrew as the package manager. I run this command:

brew update

But I got this error:

error: unable to unlink old 'bin/brew' (Permission denied)

Error: Failed while executing git pull http://github.com/mxcl/homebrew.git master

Running again under sudo:

/usr/local/Library/Homebrew/brew.h.rb:1: warning: already initialized constant FORMULA_META_FILES
/usr/local/Library/Homebrew/brew.h.rb:2: warning: already initialized constant PLEASE_REPORT_BUG error: The following untracked working tree files would be overwritten by checkout:

.gitignore
;;; big list goes here ;;;;

And now, every brew command generates these warning:

/usr/local/Library/Homebrew/brew.h.rb:1: warning: already initialized constant FORMULA_META_FILES
/usr/local/Library/Homebrew/brew.h.rb:2: warning: already initialized constant PLEASE_REPORT_BUG

Any idea what is going wrong?

3

3 Answers

42
votes

It sounds like half of it updated before it errored out, and now it's in a bad state. You may want to

cd /usr/local && git reset --hard HEAD

That should reset all git-controlled files (e.g. homebrew) back to their pristine versions. You may need to sudo that git command. After that, you can attempt to fix the permissions however you want (this may be as simple as running sudo chown -R yourname:staff /usr/local if no files in that dir need to be owned by someone else).

1
votes

Make sure that /usr/local/bin has write permissions for the user account.

0
votes

I had a similar issue today, this pointed me in the right direction, but the reset was not enough. I am not sure how, but somehow I had quite a few untracked files, I noticed after running git status.

I finally made a copy of all the files (just to be safe) and deleted them, after that brew update worked like a charm