Monday, February 13, 2012

Ruby 1.9.3 via RVM on Mac OSX Lion: Success Story

Ruby 1.9.3: freakin' fast bro!
That fast!

After a long time away from Rails and Ruby, I roll up my sleeves today and try to figure out what I’ve missed lately:

  • first, Rails 3.2 proves to be engineered to work faster in dev mode, by now incorporating the Active Reload gem by default.
  • then reading some more, Ruby 1.9.3 bubbles up — it’s freaking fast bro!

Great news, time for our good old friend RVM:

  1. $ rvm get head
  2. $ rvm reload
  3. $ rvm install 1.9.3

But wait…

The Problem

Installing Ruby from source to: /Users/marius/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...

ruby-1.9.3-p0 - #fetching 
ruby-1.9.3-p0 - #extracted to /Users/marius/.rvm/src/ruby-1.9.3-p0 (already extracted)
Fetching yaml-0.1.4.tar.gz to /Users/marius/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/marius/.rvm/src
Configuring yaml in /Users/marius/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/marius/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/marius/.rvm/usr
ruby-1.9.3-p0 - #configuring 
ERROR: Error running ' ./configure --prefix=/Users/marius/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/marius/.rvm/usr ', please read /Users/marius/.rvm/log/ruby-1.9.3-p0/configure.log
ERROR: There has been an error while running configure. Halting the installation.

The installer fails with an error message including checking whether the C compiler works... no even with Xcode 4.2 available.

The Wrong Path

Checked configure.log, found all the questions on SO and went for the fast solution:

$ rvm reinstall 1.9.3 --with-gcc=clang

which didn’t work for me!

The Solution

Following mpapis’ advice, I downloaded the GCC Installer for OSX 10.7+, v2, by Kenneth Reitz, and a simple

$ rvm reinstall 1.9.3

did the trick! So I was happy to jump to the next step:

$ rvm --default use 1.9.3

The Bonus

Downloading and installing the massive Xcode tool suite (2.5GB!!!) is a huge hassle if you just want GCC and related tools.

The osx-gcc-installer includes the essential compilers:

  • GCC
  • LLVM
  • Clang
  • Developer CLI Tools (purge, etc)
  • DevSDK (headers, etc)

Therefore, since I’m not planning to use Xcode for other reasons, I simply removed it:

$ sudo /Developer/Library/uninstall-devtools –mode=all

If the Rails install fails with a message along these lines:

ERROR:  Error installing rails:
 ERROR: Failed to build gem native extension.

        /Users/marius/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
creating Makefile

sh: make: command not found
don't worry, just run the GCC Installer once again.


  1. Ha...had the same problem this morning.

    1. Jürgen, glad you found the right solution! ;o)

  2. whoa! can rvm be patched to make this just work?

    1. @roger this is not an RVM issue, it's Apple who removed GCC and left users with LLVM when not everything is ready for it, especially older rubies and gems with native extensions. Generally I know only ruby 1.9.3 is LLVM ready anything else ...

  3. This is epic. I was just having this problem on Friday...this article shows up in my RSS feed today....internet Gods do exist.

  4. Just as a heads up to rails and iOS devs who don't want to use the osx-gcc-installer: If you get this error with Xcode installed (using --with-gcc=clang), a reinstall of Xcode fixed things for me.

  5. Just worked for me but if I do `which gcc` I get `/usr/bin/gcc` maybe Macports installed it?

  6. Now GCC/Clang is separate from Xcode (>= 4.3) and you need Command Line Tools for Xcode which you can get from


    1. Thank you Mihai, this is great news indeed!

      [At least for us using 10.7+]

  7. You are the boss! Thanks for the fix!

  8. Finally a solution that worked! Thanks

  9. dude you'r the best, i've trying to install ruby on mac for a while, finally i got your solution.

    thank you so much :)


  10. I've been running 1.9.2 on rvm for the longest time, and couldn't upgrade to 1.9.3. Nothing on StackOverflow could solve it.
    There's still a god!!! Thank you so much!

  11. PERFECT! thank you so much. i was banging my head against my mac for a few hours this am. you should post this to SO if you haven't never came up in all of my searches.

  12. Glad it helped you Jack!
    Feel free to share it on SO wherever you feel it answers the question.