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:

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..

Thanks mate, you’re my hero! I was scratching my head over this for AGES

http://twitter.com/rodneykeeling Rodney Keeling

Thanks! This helped solve my problem!

Alan Pinstein

Thanks so much this was killing me.

Anonymous

Yes! Thank you. Also, for anyone with a fresh install of Lion, you’ll find you don’t have another gcc version aside from the one that’s incompatible with Ruby. In that case, this q&a describes how to grab a version with either HomeBrew or MacPorts: http://stackoverflow.com/questions/6210399/how-do-i-build-gcc-on-a-mac

gcc 4.6 worked for me.

Gabe Muffington

If you’re coming from a fresh Lion + Xcode 4.2 install, you will likely not have the older gcc installed on your system. As an alternative, install https://github.com/kennethreitz/osx-gcc-installer (recommended by `rvm requirements`)