Macos – Homebrew is generating two warnings

homebrewmacospackage-managers

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?

Best Answer

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).