Can’t install Ruby under Lion with RVM – GCC issues

This answer was edited multiple times and now contains several alternative solutions. Try the simple “Edit 3” solution first.

Ruby 1.9.3-p125 and later have official support for clang, so if you are installing such a version you should not need GCC. If you’re installing an older version of Ruby, read on.

To compile Ruby with GCC, you need a non-LLVM version of GCC, which is no longer included with Xcode 4.2. Install it yourself (or downgrade to Xcode 4.1 temporarily), then do CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3 --enable-shared (substituting the path to your non-LLVM gcc).

Edit: https://github.com/kennethreitz/osx-gcc-installer/downloads may help for installing GCC. There is also some info available by running rvm requirements.

Edit 2: For an easier solution, you can try adding --with-gcc=clang to the arguments to configure for Ruby to use clang instead of GCC.

Edit 3: rvm install 1.9.3 --with-gcc=clang does that for you.

Note: With current versions of Xcode you need to install the command-line tools separately from the Xcode menu -> Preferences -> Downloads -> Components. This is a pre-requisite for doing any compiling with Xcode on the command-line, not just Ruby.

Note 2: If something doesn’t work after following the steps, try doing a reboot or re-login to ensure that the environment gets set correctly.

Note 3: Ruby versions prior to 1.9.3-p125 may not always be fully compatible with clang, so test your software thoroughly if using the “edit 3” solution in a production environment.

Leave a Comment