brew install mongodb error: Cowardly refusing to `sudo brew install' Mac OSX Lion brew install mongodb error: Cowardly refusing to `sudo brew install' Mac OSX Lion mongodb mongodb

brew install mongodb error: Cowardly refusing to `sudo brew install' Mac OSX Lion


The lazy (brew) way:

ls -al /usr/local/bin/brew #confirm brew ownershipsudo chown root:wheel /usr/local/bin/brewsudo brew install mongodbsudo chown <your user>:<your group> /usr/local/bin/brew  #revert ownership

The non-brew way:


I keep hitting this same problem over and over with different brew packages (today it was ImageMagick), so I keep coming back to this page. I'm just going to leave my version of the above instructions for myself, and maybe someone else will find it handy too

ls -al `which brew` # note user/groupsudo chown root:wheel `which brew`sudo brew install <package name>sudo chown <your user>:<your group> `which brew` # revert ownership

using which brew in back ticks substitutes your path to brew.

(and how do I escape backticks?)


I kept getting this error before realizing-- I WAS SUDO SU'd!

In other words, I had a root prompt and was trying to run brew install . Do not try to install using brew if your command prompt has a # at the end.

I feel dumb about it, but maybe this will help someone else.