Building Gems with native extensions on Mountain LionEdit

So with the update to Mountain Lion most attempts to build RubyGems with native components fail spectacularly with variants of the form:

make: /usr/bin/gcc-4.2: No such file or directory

Not wanting to sink endless hours into diagnosing and working around the problem, I have temporarily suppressed my natural loathing of OS X package management tools and followed the instructions here:

$ su [admin-user]
$ ruby <(curl -fsSk
$ brew doctor
$ brew tap homebrew/dupes
$ sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

This unblocks me for now. Moving forward my preference is to achieve this without relying on Homebrew (the fact that it wants to mess with the ownership and permissions on /usr/local/ horrifies me).


After a while I revisited this topic and uninstalled Homebrew to see if the issue was resolved or not:

$ cd /usr/local
$ sudo rm -rf Cellar
$ sudo brew prune # perms were "messed up", needed to use sudo
$ sudo rm -rf Cellar Library bin/brew share/man/man1/brew.1 .gitignore /Library/Caches/Homebrew

I then tried uninstalling and reinstalling some gems with native extensions; things seem to be working (this is on OS X 10.8.2 Mountain Lion, with Xcode 4.6 installed).

If it turns out that things break again in the future, a simple symlink as suggested in these Stack Overflow posts is probably sufficient: