How to link to a new gcc version with brew?

gcc, homebrew, macos

Solution

I solved it by running the following commands

brew unlink gcc
brew rm gfortran
brew cleanup
brew link gcc

It seems that gfortran was linked to the old gcc version.

Problem

I just got a new gcc version by running `brew update` and `brew upgrade`. brew complained that `brew link` did not complete successfully: ``` ~ ✓ brew upgrade ==> Upgrading 1 outdated package, with result: gcc 4.8.2_1 ==> Upgrading gcc ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gcc-4.8.2_1 ######################################################################## 100,0% ==> Pouring gcc-4.8.2_1.mavericks.bottle.tar.gz Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local You can try again using: brew link gcc Possible conflicting files are: /usr/local/bin/gfortran -> /usr/local/Cellar/gfortran/4.8.2/bin/gfortran /usr/local/share/man/man1/gfortran.1 -> /usr/local/Cellar/gfortran/4.8.2/share/man/man1/gfortran.1 ``` So I ran `brew link gcc` manually: ``` ~ ✓ brew link gcc Linking /usr/local/Cellar/gcc/4.8.2... 25 symlinks created ``` Now when I tell brew to clean up I get the following warning: ``` ~ ✓ brew cleanup Warning: Skipping (old) /usr/local/Cellar/gcc/4.8.2 due to it being linked ``` There are two gcc version in my Cellar: ``` ~ ✓ ls /usr/local/Cellar/gcc 4.8.2 4.8.2_1 ``` Do I need both? I would like to remove the old version. How can I achieve that?

Original source