Posterous theme by Cory Watilo

Trouble installing Rubygems with C extensions on Mac OS X Lion (with Xcode 4.2.1)

If you're having trouble installing Rubygems with native C extensions on Mac OS X Lion, it's because the default C compiler on 10.7 (as part of Xcode 4.2.1) is llvm-gcc-4.2 - which unfortunately does not work with many gems. You can confirm this by running

ls -la /usr/bin/gcc # it will return /usr/bin/llvm-gcc-4.2

The solution is to install the regular GCC compiler, you can download it from here: https://github.com/kennethreitz/osx-gcc-installer

Once you do this, you need to set the CC compiler in your ~/.rvmrc (I assume you're using RVM right? Why aren't you?)

Add this line to your ~/.rvmrc file:

export CC=/usr/bin/gcc-4.2

This is detailed in the Phusion Blog (thanks guys)