Lion, RVM and Ruby 1.8.7 woes

I’ve just one of the new Sandy Bridge MacBook Airs with a fresh copy of Lion and I’m really pleased with it. But that’s for another blog post. This blog post is about the massive issues I had getting a working Ruby environment set up that matched my environment on Snow Leopard.

I use RVM, and at work I use Ruby 1.8.7 (moving to 1.9 means managing multiple environments server side which sounds like a world of pain, but needs to be done at some point). Oblivious, I installed RVM and Ruby 1.8.7 in the usual way but discovered that whenever I tried to install a gem I would get a cryptic Segmentation Fault:

/Users/m/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault

I searched on the web and found advice to add CC=/usr/bin/gcc-4.2 to the start of the rvm install 1.8.7 command. I did this but would find that I would only be able to install gems in that session, and next session it would fault again.

It seems like I wasn’t uninstalling Ruby properly. You need to run rvm remove 1.8.7 (rather than rvm uninstall) and potentially (I’m not sure if this is required) remove all gems with rvm remove 1.8.7 --gems and the archive with rvm remove 1.8.7 --archive and then go into ~/.rvm and hunt down any leftovers of 1.8.7 and remove it all. Then, install 1.8.7 with the command mentioned above and you should hopefully be set.

Doing this also stopped any issues I had with rake (a cross-thread violation) which tends to suggest a borked Ruby install (must’ve been what I had).

The issue is Lion defaults to the new LLVM compiler, and 1.8.7 doesn’t like that. Apparently 1.9 doesn’t have the same issue, so that’s another reason to update the development environment at work..

This entry was posted in Blog. Bookmark the permalink.