Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permissions error while installing Homebrew

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?

like image 713
Jules Avatar asked May 29 '26 05:05

Jules


2 Answers

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
  • http://developpeers.com/blogs/fix-for-homebrew-permission-denied-issues

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.

like image 60
Parker Avatar answered Jun 01 '26 22:06

Parker


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)"
like image 44
Alec Jacobson Avatar answered Jun 01 '26 21:06

Alec Jacobson