Installing in Homebrew errors

RubyPermissionsRvmHomebrew

Ruby Problem Overview


Attempting to install rvm and ruby 1.9.2

I already installed homebrew and git, but couldn't get complete updates because I kept getting permission errors. Re-installed Snow Leopard and repaired permissions.

Now this happens...

>$ brew install wget > >Error: Cannot write to /usr/local/Cellar

Ruby Solutions


Solution 1 - Ruby

>sudo chown -R $USER /usr/local

You'll have to give yourself ownership of /usr/local/ using that line right there. I had to do this myself after using the ruby one-liner at the top of the official docs to install Homebrew. Worked like a charm for me. It ought to be the only time you'll ever need to sudo with Homebrew.

I'm not sure if the ruby one-liner does this. If it did, then something else on my system took control of /usr/local since.

Edit: I completely missed this, but @samvermette didn't (see replies to my answer): if you run this command above and have something installed via homebrew that requires special user permissions, like mysql, make sure to give those permissions back (as the above command gives recursive ownership to everything inside /usr/local to you ($USER). In the case of mysql, it's…

> sudo chown -RL mysql:mysql /usr/local/mysql/data

Solution 2 - Ruby

I had this issue after upgrading to Mavericks, and this page was the top search result when googling the error message. I continued searching and found [this answer on stack overflow.com][1]. Put concisely, it is:

sudo chmod a+w /usr/local/Cellar

This fixed the issue for me, and as it only changes permissions for the specific path referenced in the error message, seemed unlikely to have negative side effects with other installations.

I'm putting this answer here for anyone else who may find this page first like I did. However, credit should go to [jdi][2].

[1]: https://stackoverflow.com/questions/9800527/homebrew-install-permissions-issue "here" [2]: https://stackoverflow.com/users/496445/jdi

Solution 3 - Ruby

You can allow only Admin users writing into /usr/local/?

chgrp -R admin /usr/local
chmod -R g+w /usr/local
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew

Since that each user who belongs to Admin group, will be able to install new dependencies.

Solution 4 - Ruby

On High Sierra you need the following command cause chown will not work:

> sudo chown -R $(whoami) $(brew --prefix)/*

Link:

https://github.com/Homebrew/brew/issues/3228

Solution 5 - Ruby

uninstall and re install HomeBrew that will do the trick

Solution 6 - Ruby

I suggest ensuring that the current user is a member of the group that owns /usr/local. I believe by default, that group is wheel. To make yourself a member of that group:

$ sudo dscl . append /Groups/wheel GroupMembership $USER

Although something of an inelegant hammer, it has the intended effect - enabling access to items in /usr/local that are intended only for use (read/write) by elevated members. This approach has benefits of the other above because it takes advantage of the group memberships, enabling multiple (authorized) users on the system to use homebrew.

Solution 7 - Ruby

How did you install Homebrew? Their official installation instructions include running a ruby script. That should take care of the permission issues for you.

If you don't want to run a script, there is a section of that page called "Installing to /usr/local for Developers" that explains the change in permissions needed for the /usr/local directory.

Solution 8 - Ruby

EDIT: As mentioned in the comments it's a bad idea to use sudo with homebrew, so don't use the following answer!


You can also prevent this error if you execute the command with sudo:

$ sudo brew install wget

But take care of using sudo because you can make a lot of mistakes.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIbrahimView Question on Stackoverflow
Solution 1 - RubyBen KreegerView Answer on Stackoverflow
Solution 2 - RubyNathanView Answer on Stackoverflow
Solution 3 - RubySeb WilgoszView Answer on Stackoverflow
Solution 4 - RubyMetodij ZdravkinView Answer on Stackoverflow
Solution 5 - RubyRicardo MarinView Answer on Stackoverflow
Solution 6 - RubyJason R. CoombsView Answer on Stackoverflow
Solution 7 - RubyjhuebschView Answer on Stackoverflow
Solution 8 - RubyPascalView Answer on Stackoverflow