Getting Ruby 1.8.7 Installed on RVM

RVM - Ruby's Manager

Today I had a need to install ruby 1.8.7 to work in a repo here at The Shop. Normally, rvm would make this easy by allowing me to simply load it up:

  $ rvm install ree-1.8.7-2010.02

but the upshot of this is a problem in the compilation:

  Error running './installer -a /Users/me/.rvm/rubies/
  ree-1.8.7-2010.02 --no-tcmalloc --dont-install-useful-gems -c',
  please read /Users/me/.rvm/log/ree-1.8.7-2010.02/install.log

  There has been an error trying to run the see installer,
  Halting the installation.

After a ton of trying things, the solution is to use Homebrew's gcc 4.2 as it's not based on the LLVM, as the one that ships with Xcode 4.2 is. It turns out that there's a problem with the compile of some of the ree-1.8.7-2010.02 components when using the LLVM-based compiler.

OK, so we need to get the see what we're trying to get:

  $ brew search gcc
  homebrew/dupes/apple-gcc42
  (among other things)

If the homebrew/dupes doesn't appear, then you don't need this step, but I did:

  $ brew tap homebrew/dupes

and then we can install GCC 4.2 without the LLVM:

  $ brew tap apple-gcc42

This places gcc-4.2 in the path if you have Homebrew set up properly.

All this was to be able to properly compile ree-1.8.7-2010.02, so now we can do that:

  $ CC=gcc-4.2 rvm install ree-1.8.7-2010.02 --with-gcc=gcc-4.2

At this point, it will all install nicely and you'll have ree-1.8.7-2010.02 in your RVM set-up. Lots of work, but all worth it.