Search code examples
mongodbhomebrew

Permissions When Attempting to install mongodb


I am trying to install mongoDB and need to tap their repo with homebrew. However, every time I run the command, I get a permission error. I am on macOs if that helps

I tried running it with and without sudo and get errors either way.

brew tap mongodb/brew

It should just tap the repo

Without Sudo-

touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied
touch: /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/.git/FETCH_HEAD: Permission denied

With Sudo-

Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

Solution

  • I figured out the issue. I had the change the permissions of the

    /usr/local/Homebrew
    

    directory so that it could be edited by anyone. I did this using the GUI, but you could do it using this command

    cd /usr/local && sudo chown -R 777 Homebrew