How to fix error: Could not symlink lib/gcc/4.9?

1

1

I would like to install gcc with homebrew on a MacBook Pro (OS X 10.10.3) and ran into this:

mach:gcc mh$ brew install gcc
Warning: gcc-4.9.2_1 already installed, it's just not linked
mach:gcc mh$ brew link gcc
Linking /usr/local/Cellar/gcc/4.9.2_1... 
Error: Could not symlink lib/gcc/4.9
/usr/local/lib/gcc is not writable.

What can I do? (adjusting the permissions of /usr/local/lib/gcc?

Marius Hofert

Posted 2015-05-10T19:18:05.593

Reputation: 184

Answers

3

The error:

/usr/local/lib/gcc is not writable.

means that your /usr/local/lib folder is not writable for brew.

Therefore you should fix the wrong permissions first by:

sudo chown -R $USER /usr/local/lib /usr/local/include /usr/local/bin /usr/local/Cellar

Then if this still doesn't work, run:

brew doctor

to check your system for potential other problems which you may have.

Similar issue: Brew doctor says: “Warning: /usr/local/include isn't writable.” at SO

kenorb

Posted 2015-05-10T19:18:05.593

Reputation: 16 795

Thanks for helping. I think it should be -R (uppercase). Before changing permissions, I checked (in the Terminal) and they were already set correctly, but executing chown indeed helped. Seems strange. – Marius Hofert – 2015-05-10T20:11:54.913

@MariusHofert I've fixed typo, thanks. Sometimes when you run brew with sudo, it breaks the permissions, so you've to re-run the chown again then. – kenorb – 2015-05-10T20:13:52.190