Installing Ruby 1.9.3 on Mac OS X Lion with RVM

Note: the default ruby version on Mac OS X Lion (10.7.3) is 1.8.7

Install RVM

An easy way to install and switch between ruby version is to use RVM (Ruby Version Manager). RVM make installing multiple ruby interpreters / runtimes easy and consistent.

  • Download and install latest RVM version
$ curl -L https://get.rvm.io | bash -s stable

Install Ruby

To compile ruby, you need a C compiler. If you have XCode installed, you might encounter several issues while compiling. The easiest way I found to fix this is to download osx-gcc-installer (GCC-10.7-v2.pkg) and install it.

You can install RVM as root for your whole system or proceed with a user install as follow:

$ CC=/usr/bin/gcc-4.2 rvm install 1.9.3

The CC variable tell our installer to use the freshly downloaded gcc.

Use our new ruby version:

$ rvm use 1.9.3
Using /Users/charles/.rvm/gems/ruby-1.9.3-p194
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]

Et voilà!

Notes

Quick links you get during RVM install:

  • RTFM: https://rvm.io/
  • HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
  • Cheatsheet: http://cheat.errtheblog.com/s/rvm/
  • Screencast: http://screencasts.org/episodes/how-to-use-rvm

 

 
  • There is an even easier way with RailsInstaller for OSX, it includes osx-gcc-installer, RVM, Ruby and Rails already ready to use, and there is no need to install additional libraries for Ruby, Bundler and Rails to work correctly, everything needed is bundled in -> http://railsinstaller.org

    You can always uninstall Rails `gem uninstall rails` if you do not need it.