Chromed Shark

My various ramblings about programming

Installing Ruby 1.9.2 Using RVM and Homebrew on Lion

There seem to be a lot of people having trouble installing Ruby 1.9.2-p290 under Lion, based off of the many blog posts about changing the C compiler and using MacPorts, Homebrew, and/or RVM to install a bunch of dependencies. Below is the process that I used to install it. I’m not quite sure why RVM automatically used /usr/bin/gcc-4.2 to compile everything on my computer, and why some people need to set some environment flags to change their default compiler to this. If you are getting compiler errors, you may need to run export CC=gcc-4.2 before the rvm install step.

First, we’re going to install a newer version of the readline library. I used Homebrew for this, but you should be able to use rvm pkg install readline as well.

brew install readline

Once that is finished, take note of where Homebrew said it installed readline. For me, that path was /usr/local/Cellar/readline/6.2.1 (minus the lib directory).

Next, we’re going to update RVM to make sure there aren’t any issues with Lion and Ruby 1.9.2 that haven’t been solved in the latest release.

rvm get latest
# rvm get head upgrades to the latest dev release

The last step in this process is to install Ruby 1.9.2-p290. If you used RVM to install readline, your path for readline should be changed to $rvm_path/usr. If you are using MacPorts, your readline path should be changed to /opt/local.

rvm install 1.9.2 -C --enable-shared,--with-readline-dir=/usr/local/Cellar/readline/6.2.1 \
--with-iconv-dir=/usr --with-zlib-dir=/usr --with-openssl-dir=/usr,\