I'm trying to install Homebrew on an older, not-so-well maintained box running OS X 10.9.2. When I use the autoinstall script from Homebrew's website:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I get a series of permissions errors:
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 207213, done.
remote: Compressing objects: 100% (55712/55712), done.
remote: Total 207213 (delta 150324), reused 207201 (delta 150315)
Receiving objects: 100% (207213/207213), 43.70 MiB | 5.35 MiB/s, done.
Resolving deltas: 100% (150324/150324), done.
From https://github.com/Homebrew/homebrew
* [new branch] master -> origin/master
error: unable to unlink old 'Library/Homebrew/extend/ENV/shared.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/extend/ENV/std.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/extend/ENV/super.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/hooks/bottles.rb' (Permission denied)
error: unable to create file Library/Homebrew/language/go.rb (Permission denied)
error: unable to create file Library/Homebrew/language/haskell.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/language/python.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/fortran_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/language_module_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/ld64_dependency.rb' (Permission denied)
error: unable to create file Library/Homebrew/requirements/maximum_macos_requirement.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/minimum_macos_requirement.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/mpi_dependency.rb' (Permission denied)
error: unable to create file Library/Homebrew/requirements/osxfuse_dependency.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/python_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/x11_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/utils/inreplace.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/utils/json.rb' (Permission denied)
error: unable to create file Library/Homebrew/utils/popen.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/vendor/okjson.rb' (Permission denied)
fatal: Could not reset index file to revision 'origin/master'.
Failed during: git reset --hard origin/master
Why do these issues occur? As far as I can see (based on the first line of the above snippet), Homebrew's install script performs a chmod on that directory to give it appropriate permissions.
How can I resolve this issue?
You need to reset permissions to /usr/local
brew update
brew upgrade
brew cleanup
brew install node
brew link --overwrite node
sudo chown -R `whoami` /usr/local
In some cases brew update fails with similar errors. In that case, first reset your permissions using chown and then run brew update and the rest of the commands.
I got the same errors when trying to install/update brew on a machine with an old, half-uninstalled brew. I first followed the uninstall command
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Then issued the install command
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
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