Skip to main content

Installing (painlessly) Ruby 1.9.3 into Mac OS X

Update: Nov. 2012. I no longer recommend rbenv, I now recommend RVM (ruby version manager) since both require Xcode to function. And the latest JRuby (1.7.0) now defaults to 1.9.3 and doesn't require the --1.9 switched to be passed or a JRUBY_OPTS variable set.
(I also updated the post to reflect the proper capitalization of JRuby vs. Jruby, which is incorrect.)

Installing the latest version of Ruby on Mac OS X is a bit more complicated than it should be. There are no .dmg installers and the built in version 1.8.7 is quite old now.  There are various ways of installing ruby on a Mac and here is a list from the least painful to the most annoying.

  1. Using JRuby or MacRuby are the least painful way to install Ruby 1.9 to OS X. They come with their own .dmg installer, it's easy and fast. Unfortunately JRuby (although it includes 1.9) defaults to 1.8 so you have to go into your .bash_profile file and add a line there. See previous blog here. Note that because ruby is already installed on the Mac you'll have to use JRuby/MacRuby vs. ruby, jgems/macgems vs. gems and jirb/macirb vs. irb on the command line, and to run rails in JRuby it's the arcane jruby -S rails. I haven't gotten rails to run well with MacRuby yet, but MacRuby is the way to go for integration with the Mac. MacRuby plays well with Xcode too. But one thing both of these have against them: they're not 1.9.3, they only go to 1.9.2.
  2. Using ruby_build with rbenv mostly painless but there are a few snags I hit and below is an explanation on how I installed it and how to avoid the snags.
  3. Using RVM with Xcode. Rvm or the ruby version manager is the way to go on Linux but on the Mac it requires the gargantuan (and thankfully now free) Xcode to be installed. Once you have Xcode on board it should be easy sailings (mostly). Though if you use Netbeans watch out it has not so good interaction with rvm's rubies.
  4. MacPorts or HomebrewI haven't played around with these because they requires Xcode to install, but looks straight forward. Macports has an dmg installer. And Homebrew looks like it's even easier. Homebrew is actually written in ruby. There is also Fink but I haven't heard much about it. 
  5. Install from source (Painful! And no I haven't tried it). I've installed ruby from source on Ubuntu and the process was straight forward-ish but on the Mac I'm not so sure. My guess is that the new compiled ruby will go to /usr/local/bin instead of the /usr/bin/ where the normal Ruby is but I don't know. Also this requires Xcode installed and probably some interesting work on the path. Additionally compiling from source you'll have to worry about weather you have the right headers for x or y plugin. I ended up deleting my Ubuntu compiled Ruby because the it would not play with the gtk2 ruby gem. 

Recommended: ruby_build with rbenv

  • Pros: light and fast, not much to install.
  • Cons: may not work the first time.

The first thing to install is ruby_build. First you'll need Git on your system, if you don't have it already (you should) go get that first (get further info on that at ProGit). Then go to the website There you'll see the command line inputs to get ruby_build installed.

$ git clone git://
$ cd ruby-build
$ ./

This should install ruby_build to usr/local, you may have to do sudo ./ to get it to work.

That's the easy part. Now we need to get rbenv which will allow us to get multiple version of ruby installed but more importantly Ruby 1.9.3.

To install rbenv you need to create the directory where it will go, possibly adjust the path, check your ~/.bash_profile file for errors (I had some in there), then install Ruby 1.9.3 and possibly even delete some files and then re-install it (just to be on the safe side).

The instructions on how to install rbenv are on the website. They are also almost the same as the ones for ruby_build. First create a ~/.rbenv folder and then follow the commands on the website.

Immediately after you install rbenv check your .bash_profile file and make sure it looks ok. Mine was missing a line ending between two commands and would not work until I fixed that. Also be aware that because rbenv and ruby_build work using shims you need to re-build the look up paths or re-hash every time you install anything or do what I do: close the terminal and open a new terminal window.

Once you have rbenv installed you need to install Ruby 1.9.3 into it and ruby build uses this command shortcut to do it.
rbenv install 1.9.3-p0
After you install it some commands like Rails or Rake may still use the old path. I deleted these from the /usr/bin/ file and re-installed and that fixed it. But be aware that you need to re-start the terminal every-time you install. The rbenv rehash command didn't work once on mine as advertised, but restarting the terminal always did.

Recommended: JRuby

  • Pros: Easy install, works with Rails, plays well with other installations.
  • Cons: Requires the preface "jruby -S" on many commands, defaults to 1.8.7, doesn't have 1.9.3 yet.

To install Jruby just download the dmg installer from and follow the install instructions. To access Jruby just type jruby and the file name or jruby -S and the command. Additionally there a two shortcuts to the gem and irb commands in jgem and jirb. Also try out jirb_swing which is an irb session in a swing windows and has auto-complete.

To set JRuby to default to 1.9.2 you have to edit your .bash_profile file, more info on this blog post.
To use Rails with JRuby you may have to use the Java version of many gems, more info on this blog post.

JRuby is a good back up ruby and works fairly well overall. Don't be worried if the start-up seems to take forever, it's because it's loading all of Java first. Once Java is loaded it runs pretty well.


Popular posts from this blog

How to configure Ubuntu's keyboard to work like a Mac's

Typing accents on a PC is a complicated Alt + three numbered code affair. One feels like a sorcerer casting a spell. "I summon thee accented é! I press the weird magical key Alt, and with 0191 get the flipped question mark!" For a bilingual person this meant that writing on the computer was a start-and-stop process. With Mac's it a whole lot easier, just Alt + e and the letter you wanted for accents and alt + ? for the question mark. No need to leave the keyboard for the number pad and no need to remember arcane number combinations or have a paper cheat sheet next to the keyboard, as I've seen in virtually every secretaries computer in Puerto Rico.

Linux has a interesting approach to foreign language characters: using a compose key. You hit this key which I typically map to Caps Lock and ' and the letter you want and voilá you get the accent. Kinda makes sense: single quotation mark is an accent, double gets you the ümalaut, works pretty well. Except for the ñ, wh…

Contrasting Styles of Writing: English vs. Spanish

There is interestingly enough a big difference between what's considered good writing in Spanish and English. V.S. Naipul winner of the 2001 Nobel prize for literature publish an article on writing. In it he emphasizes the use of short clear sentences and encourages the lack of adjectives and adverbs. Essentially he pushes the writer to abandon florid language and master spartan communication. This is a desired feature of English prose, where short clipped sentences are the norm and seamlessly flow into a paragraph. In English prose the paragraph is the unit the writer cares about the most.

This is not the case in Spanish where whole short stories (I'm thinking this was Gabriel Garcia Marquez but maybe it was Cortázar) are written in one sentence. Something so difficult to do in English that the expert translator could best manage to encapsulate the tale in two sentences. The florid language is what is considered good writing in Spanish but unfortunately this has lead to what …

Fixing Autocomplete in Github's Atom Text Editor for Ruby

I really like Github's Atom Text Editor. I really like that it's multi-platform allowing me to master one set of skills that is transferable to all platforms and all machines. 

On thing that just burns me of the default set-up in Atom is the Autocomplete feature that seems to change my words as a type them. Because Ruby uses the end of line as a terminus for a statement you usually finish a word with pressing the return button and you get really annoying changes to your finished typed word a la MS Word. I find myself yelling "No that's not what I wrote!" at the screen in busy coffee shops.

I disabled autocomplete for a while but it is a very useful function. Then I found out they changed the package that gave the autocomplete to a new one called "Autocomplete Plus" that gives you more options. All that I needed to change to make autocomplete sane again:

1. Open Atom's Preferences
2. Search the bundled packages for "Autocomplete Plus"

3. Go to t…