Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I installed git or upgrade git via brew I couldn't link it with brew link git. If I try sudo brew link git I get:

cowardly refusing to sudo brew link

It says that I have to check the permissions on:


I chmoded everything to 777 but I'm not sure if it is good.

I can now link git. Should I change the permission to something less permissive?

share|improve this question
up vote 5 down vote accepted

777 permissions aren't necessarily bad here – you'll probably never run into permissions problems, and it's not a huge security issue I'd say.

Anyway, the "normal" permissions on /usr/local/share that Homebrew requires should be (recursively) 755, thus rwxr-xr-x.

chmod -R 755 /usr/local/share

At least brew shouldn't need sudo permissions to ever do anything in there. Only /usr/local is owned by root, but writable for the staff group, in which your user should be in.

For fixing existing Homebrew installations, check out this gist, which is a script that will attempt to correct your /usr/local permissions.

As an example, here's the directory listing of one of my (sane) Homebrew installations with ghostscript being the only exception that needed a sudo brew link:

aeneas:local werner$ ls -la /usr/local/share/
total 40
drwxr-xr-x  11 werner  staff  374 Mar  5 14:53 .
drwxrwxr-x  14 werner  staff  476 Feb 28 12:51 ..
drwxr-xr-x   6 werner  staff  204 Mar  5 14:54 aclocal
drwxr-xr-x   8 werner  staff  272 Mar  5 14:53 doc
lrwxr-xr-x   1 werner  staff   34 Feb  8 12:26 ffmpeg -> ../Cellar/ffmpeg/0.10/share/ffmpeg
drwxr-xr-x   4 werner  wheel  136 Apr 16  2010 ghostscript
lrwxr-xr-x   1 werner  staff   36 Mar  5 14:53 git-core -> ../Cellar/git/
lrwxr-xr-x   1 werner  staff   35 Mar  5 14:53 git-gui -> ../Cellar/git/
lrwxr-xr-x   1 werner  staff   32 Mar  5 14:53 gitk -> ../Cellar/git/
lrwxr-xr-x   1 werner  staff   34 Mar  5 14:53 gitweb -> ../Cellar/git/
drwxr-xr-x   9 werner  staff  306 Mar  5 14:53 man
share|improve this answer
For more diagnosing steps, run brew doctor. – slhck Mar 6 '12 at 22:50
Unfortunately, brew doctor does not give any useful information in this case. The mentioned gist fixed a similar problem for me, thanks :) – TheDeadSerious Jun 6 '12 at 13:58
once I installed brew I've not needed to use sudo for much of anything. Perhaps you sudo'd something you shouldn't have at some point which got the permissions and or ownership out of whack? – dstarh Dec 19 '13 at 19:08
@dstarh That's usually the issue. These days Homebrew shouldn't do anything when sudo is used. – slhck Dec 19 '13 at 19:15
Why doesn't Homebrew allow us to use sudo? We keep having to mess with our permissions to link things when it should just let us sudo brew link [package] like apt-get does. I just copy the libraries from the cellar myself every time I want to update something rather than trying to deal with this. – sudo Jul 7 '14 at 23:41

I haven't tried the gist yet, but tried to chmod 775 on the folder. As it owned by root:wheel it cannot be changed. I referenced a Japanese site.

sudo chown yourusername:admin -R /usr/local/share/ghostscript
brew link ghostscript
brew doctor

then it works for me above.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .