just trying to find the answer…

Updating MacOS X to Ruby 2.0

ruby2MacOS X comes with ruby by default. It’s great, but what if you want to join the cutting edge and use Ruby 2.0 and Rails 4 like all the cool kids?

First, let’s look at which version we have installed.

Heinrichs-iMac:~ hbeck$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

I like things simple, so let’s find a simple way to update this.


Fortunately there is a simple package manager called “Homebrew” which makes life very easy. I like easy.

Installing it takes one line in the terminal:

Heinrichs-iMac:~ hbeck$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

After you install, pay attention to the instructions. You may need to run a command to update it, which you should do.


Some people prefer to manage their versions of Ruby using RVM. I prefer to use rbenv. It’s simpler and lightweight. The documentation for rbenv is here.

Heinrichs-iMac:~ hbeck$ 
brew update
brew install rbenv
brew install ruby-build
brew install openssl  #this part might be optional, if it is, you will get a notice saying, "already installed"
CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` rbenv install 2.0.0-preview1

the last command will take a while to run.

When it finishes, you can run this command to see WHICH versions of ruby are installed

Heinrichs-iMac:~ hbeck$ rbenv versions
* system (set by /Users/hbeck/.rbenv/version)

So the asterisk shows that there is a system ruby (which we already is know 1.8.7) and a cool hotrod 2.0.0-preview1 available.

Since we installed rbenv, we need to tell our $PATH profile to use the settings from rbenv and then “restart” the shell to use the new settings

Heinrichs-iMac:~ hbeck$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
Heinrichs-iMac:~ hbeck$ exec $SHELL -l

Let’s make that hotrod switch! You will need to CAREFULLY type the name of the version, so watch that you get all the characters correct.

Heinrichs-iMac:~ hbeck$ rbenv local 2.0.0-preview1

So let’s verify that we have the correct version.

Heinrichs-iMac:~ hbeck$ ruby -v
ruby 2.0.0dev (2012-11-01 trunk 37411) [x86_64-darwin12.4.0]


Google Latitude is set to zero


Have you read this PDF?


  1. Glen

    Thanks for this, but I’m not getting the expected result.

    All commands go as expected, until the very last, which still shows the original version. I’ll check with rbenv Github and report back when I get things to work.

    OS X 10.6.8

    dev:JavaScript glen$ rbenv versions
    * 2.0.0-p247 (set by /Users/glen/Documents/JavaScript/.ruby-version)
    dev:JavaScript glen$ ruby -v
    ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0]

  2. Glen

    The solution turned out to be deleting the local .ruby-version. Odd since it _did_ contain the desired version.

    dev:JavaScript glen$ rbenv versions
    * 2.0.0-p247 (set by /usr/local/var/rbenv/version)
    dev:JavaScript glen$ ruby -v
    ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin10.8.0]

    Thanks again, your write-up was a big help.

  3. myrythm

    Great article. Just wanted to note that curl for installing homebrew is now – https://raw.github.com/Homebrew/homebrew/go/install

  4. hbeck

    I don’t speak Spanish very well, but I think you are asking, “How do I add stuff to my $PATH”?

    Well, first, check to see what variables are in your path like this echo $PATH

    To add something, do this: PATH=$PATH:~/casa/ricosuave/fijoles

    I hope this works out for you.

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress & Theme by Anders Norén