I had a weird situation once I install anything with homebrew, I stucked at:
Error: Cannot write to /usr/local/Cellar
I do
ls -la /usr
and got this
loho:~ kureikain$ ls -la /usr
total 8
drwxr-xr-x@ 13 root wheel 442 May 4 12:42 .
drwxrwxr-t 27 root admin 986 May 3 10:44 ..
drwxr-xr-x 8 root wheel 272 Jul 2 2011 X11
lrwxr-xr-x 1 root wheel 3 Dec 7 11:43 X11R6 -> X11
drwxr-xr-x 1058 root wheel 35972 May 4 12:42 bin
drwxr-xr-x 288 root wheel 9792 May 4 12:41 include
drwxr-xr-x 342 root wheel 11628 May 4 12:42 lib
drwxr-xr-x 141 root wheel 4794 May 4 12:42 libexec
drwxr-xr-x 7 root wheel 238 Jan 27 18:32 llvm-gcc-4.2
drwxrwxr-x 10 root admin 340 May 4 14:02 local
drwxr-xr-x 261 root wheel 8874 May 4 12:42 sbin
drwxr-xr-x 69 root wheel 2346 May 4 12:42 share
drwxr-xr-x 4 root wheel 136 Jul 2 2011 standalone
For some reasons, /usr/local belongs to admin group insteads of wheel. with sudo, we need to have it in group “wheel”. I recall that this happened after I manually change the username. I had an account on Mac Mini with username “vinhnguyen”. I then decided to change it, so I manually enable root account and change the name of home folder. After I do that, /usr/local became to belong to admin group.
Futher, if I continue to check /usr/local, I got:
loho:~ kureikain$ ls -la /usr/local/
total 24
drwxrwxr-x 10 root wheel 340 May 4 14:02 .
drwxr-xr-x@ 13 root wheel 442 May 4 12:42 ..
-rw-r--r-- 1 kureikain admin 159 May 4 14:01 .gitignore
drwxr-xr-x 2 vinhnguyen admin 68 May 4 11:10 Cellar
drwxrwxr-x 6 vinhnguyen admin 204 May 2 12:06 Library
-rw-r--r-- 1 kureikain admin 789 May 4 14:02 README.md
drwxrwxr-x 3 vinhnguyen admin 102 May 4 14:02 bin
lrwxr-xr-x 1 root wheel 27 May 3 10:04 mysql -> mysql-5.5.23-osx10.6-x86_64
drwxr-xr-x 16 root wheel 544 Mar 30 00:33 mysql-5.5.23-osx10.6-x86_64
drwxrwxr-x 3 vinhnguyen admin 102 May 2 12:06 share
You may get following error:
Error: Permission denied - /usr/local/include
So, I can say permission got messing up after I manually change account name from vinhnguyen to kureikain. So we need to manually correct permission again.
sudo chgrp wheel /usr/local/
sudo chown -R $USER /usr/local/
After you do that, everything should work fine.
loho:~ kureikain$ brew install wget
==> Downloading http://ftpmirror.gnu.org/wget/wget-1.13.4.tar.bz2
Already downloaded: /Library/Caches/Homebrew/wget-1.13.4.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/wget/1.13.4 --sysconf
==> make install
/usr/local/Cellar/wget/1.13.4: 7 files, 552K, built in 34 seconds