Updating / Installing Ruby in Lion

You know how they say you should learn a new language every year?  Well, I’m woefully behind on that.  I’m hoping this will be a year to finally get my head around Objective-C and Ruby to make up for lost time.

So anyway, I sat down tonight to install Ruby and actually do something.  I didn’t get to the “do something” part. But here’s how I got ruby to report the latest version (1.9.3) instead of what it came with (1.8.7).

Yay I got Ruby On Rails On Lion!
I’m on a MacBook Pro running OSX 10.7.3 (Lion).  After Googling in the dark for awhile about finding some sort of one-click installer, I finally came across a couple of helpful things:
  • RubyGems – apparently this is like NuGet (a package management system for software libraries and their dependencies), if you are coming from the .NET developer world like me.
  • RVM – “Ruby Version Manager.”  Apparently this is how all the cool kids install Ruby.  I shunned this advice I found in my early Googling, trying to use sudo and RubyGems to update it.  Which just yielded cryptic errors about missing header files.
  • Homebrew – You end up needing this for an obscure SSL management library.  All will become clear soon.  This has nothing to do with Wii Homebrew, which I love.
<disclaimer>I know nothing about Ruby (yet).  I’m not good at this.  I’m rusty at the command line.  You’ll probably read the steps I took and laugh and then suggest a simpler way.  Actually that would be awesome.  Please do that.  I’m just hoping this saves someone the time it took me to figure this out.</disclaimer>

So first off…holy cow.  I see why there’s a kickstarter project that already has almost double its asking pledge to make this easy.

Alright…now that that’s out of the way.

I’ll spare you all the dead ends I went down (and oh, there were many).  Remember…this is so when I type ‘ruby -v’ I see 1.9.3 (actually, to be clear, 1.9.3p194) instead of 1.8.7 out of the box with Lion.  Here’s what ended up working:

  1. Install Xcode
  2. Install the Command Line Tools in Xcode Preferences > Downloads
  3. Start doing the stuff on this page for RVM.  Note that I utterly ignored its warning to read all subsections under RVM.  I’ll get to that someday, I promise.
  4. Now while you were doing step #3, you might’ve said to yourself “pssh.  Requirements.  Who needs those?”  You do.  For just the straight Ruby install, it says you need Libksba.  Because, of course you do.  It’s libksba!
  5. To actually get Libksba, I found the easiest (for me, only) way to get it to work was using Homebrew.  This appears to be some sort of package / dependency manager distinct from RubyGems.
  6. Run `brew doctor` and do what it says (my only deviation was not remediating /usr/local permissions, but I did switch the Xcode path).  If you did steps #1 and #2 here, some of these will be taken care of.  For the rest, this article helped me out a lot.
  7. You’re almost home!  Now type `rvm install 1.9.3` and have a drink.  Because, man, you earned it.

…so…now what?