Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am not sure why I'm getting this error:

$ brew install mongodb
==> Downloading http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.0.4.tgz
######################################################################## 100.0%
Error: Permission denied - /usr/local/var/log/mongodb

So I try to run it with sudo:

$ sudo brew install mongodb
Password:
Cowardly refusing to `sudo brew install'

If I try to create the file myself I get this:

Error: File exists - /usr/local/var/log/mongodb

It gets even more interesting when you read this thread on homebrew's github about the error:

https://github.com/mxcl/homebrew/issues/9953

They state that brew can't write the file because it's not root, then they say it's because they think it shouldn't run as root.

These are the official install instructions, what's up?

If you have a better suggestion for installing it, then I'll forget about homebrew.

like image 683
botbot Avatar asked May 03 '12 03:05

botbot


2 Answers

The lazy (brew) way:

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

The non-brew way:

  • Download mongodb distribution from 10gen: http://www.mongodb.org/downloads
  • Install files in /usr/local/bin/
  • Create a config file in /etc/mongo.conf (minimum, tell it where to store data, and probably tell it to bind only to localhost): http://www.mongodb.org/display/DOCS/File+Based+Configuration
  • Create a startup script that calls mongod -f /etc/mongo.conf
like image 200
Eve Freeman Avatar answered Nov 09 '22 05:11

Eve Freeman


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/group
sudo 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?)

like image 31
stephan.com Avatar answered Nov 09 '22 04:11

stephan.com