0 to rbenv on Mountain Lion (late 2012 edition)

December 9th, 2012  |  Published in mac and iphone, ruby

I thought I was going to sell my 11″ MacBook Air and even had it zeroed out for handoff once I found a buyer, but I decided I missed it, so I set it back up again this weekend, reinstalling Mountain Lion. That meant getting rbenv back onto it with minimal hassle.

If you can live with plain old system Ruby (1.8.7-p358) on Mountain Lion, steps 4 and 7 don’t really matter: Ruby builds with Apple’s own compilers. If you want to have a rbenv-managed Ruby 1.8.7, you’ll need gcc, not llvm.

This is the second time in about a month I’ve been through this, and what I’ve got here represents the fastest path I could manage to get from “new Mac with Mountain Lion installed” to “rbenv that can build rubies prior to 1.9.x.”

  1. If you don’t have XCode installed, you can install the XCode command line tools found here: https://developer.apple.com/downloads/index.action . Alternately, if you don’t have an Apple account, you can get a package here: https://github.com/kennethreitz/osx-gcc-installer

  2. Install Homebrew: http://mxcl.github.com/homebrew/

  3. Install a new git from Homebrew:

    $ brew install git

  4. Install Homebrew’s gcc42:

    $ brew tap homebrew/dupes && brew install apple-gcc42

  5. Install rbenv with Homebrew:

    $ brew install rbenv

  6. Install ruby-build:

    $ brew install ruby-build

  7. For ruby 1.8.7, disable Tcl/Tk support to build with rbenv:

    $ CONFIGURE_OPTS="--without-tk" rbenv install 1.8.7-p370

That’s pretty much it. The longest part of the process is downloading and installing the command line tools (115MB), but that’s much better than downloading and installing the behemoth that is XCode, then installing the command line tools.

I suppose there’s one more thing to note, which I discovered in the process of trying to see if there was a quick way to uninstall XCode’s command line tools: There’s no command you can just run to do that, but there’s this helpful script, which I found on Cocoanetics’ website, and which seemed to do the trick:

Leave a Response

© Michael Hall, licensed under a Creative Commons Attribution-ShareAlike 3.0 United States license.