Solution 1:

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/1.7.9.2/share/git-core
lrwxr-xr-x   1 werner  staff   35 Mar  5 14:53 git-gui -> ../Cellar/git/1.7.9.2/share/git-gui
lrwxr-xr-x   1 werner  staff   32 Mar  5 14:53 gitk -> ../Cellar/git/1.7.9.2/share/gitk
lrwxr-xr-x   1 werner  staff   34 Mar  5 14:53 gitweb -> ../Cellar/git/1.7.9.2/share/gitweb
drwxr-xr-x   9 werner  staff  306 Mar  5 14:53 man