Update Aug. 2010
The RVM installer should be prefered over installation via gem:
1 | bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) |
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
If you are a Mac user and a Ruby developer you probably ran into issues with custom Ruby installations and had troubles with Gems like these:
- How to fix that Rubygems mess on Leopard
- Installing Ruby, RubyGems, and Rails on Snow Leopard
- How do I install the mysql ruby gem under OS X 10.5.4
- [...neverending list of links...]
Using MacPorts
There are a lot of people that recommend using MacPorts for installing a custom Ruby version, but there are a lot of issues with this approach too. If you did manage installing the Ruby version of choice, you might run into issues using TextMate or other tools, that depend on the default OS X Ruby (I think that I had ALL the problems one could have, but this might be an exaggeration).
Custom (X)Ruby Versions
The next problem arises if you want to use different versions of Ruby or even different implementations/runtimes (EVIL666) like JRuby, MacRuby or Rubinius.
I am currently using:
- Ruby 1.8.6 for integration with Heroku
- Ruby 1.8.7 for daily usage
- Ruby 1.9.1 for a fast Ruby experience
- MacRuby for playing around and avoid looking at verbose Objective-C code
- JRuby for Buildr
There are some simple approaches to fix this mess. MacPorts and JRuby provide different binaries to run like ruby18, ruby19 or jgem, but this is error prone and confusing. I was always installing Gems to the wrong Ruby environment and there were always conflicts with scripts and tools looking for the actual Ruby binary.
Since this did not work out quite well I started to wire the path tightly in the .profile file to include just the right Ruby and Rubygems binary. This had the drawback that I had to close terminals for every switch. So I started writing bash scripts manipulating the path directly, which worked well, but was unconvenient.
Most of the Ruby versions are not stable. Ruby 1.9 is under development, JRuby has frequent compatibility and performance releases and MacRuby is kind of an an “Alpha”.
As far as I am concerned, I always want to use the latest stable release of these distributions! Using MacPorts you often just get some release, so you have to compile stuff yourself. Doing so is time consuming and painful…
RVM to the rescue
Some weeks ago I stumbled over RVM, which can be installed as a Gem to the standard preinstalled OS X Ruby. RVM provides some neat features and does exactly what I want. It provides a simple interface to manage Ruby distributions and does some clever stuff organizing local Gems.
Right now I am using the preinstalled OS X Snow Leopard Ruby distribution with RVM and no ports:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # check that you are running default Ruby ruby -v => ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] # update your OS X Rubygems sudo gem update --system # check Gem version gem -v => 1.3.5 # install RVM as a Gem to the defaut OS X Ruby sudo gem install rvm # run RVM installation rvm-install # follow the installation instructions (add RVM to the $PATH etc) # open new terminal and check RVM version rvm --version => rvm 0.1.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/] # have a look at the manual rvm --help # install a (X)Ruby version rvm install jruby # see what is installed rvm list # see some more information rvm info # use a (X)Ruby version rvm use jruby # install a gem for the current (X)Ruby gem install buildr # install a gem for all Rubies under RVM control rvm gem install -v=0.6.9 savon # flip back to default Ruby rvm system |
# check that you are running default Ruby ruby -v => ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] # update your OS X Rubygems sudo gem update --system # check Gem version gem -v => 1.3.5 # install RVM as a Gem to the defaut OS X Ruby sudo gem install rvm # run RVM installation rvm-install # follow the installation instructions (add RVM to the $PATH etc) # open new terminal and check RVM version rvm --version => rvm 0.1.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/] # have a look at the manual rvm --help # install a (X)Ruby version rvm install jruby # see what is installed rvm list # see some more information rvm info # use a (X)Ruby version rvm use jruby # install a gem for the current (X)Ruby gem install buildr # install a gem for all Rubies under RVM control rvm gem install -v=0.6.9 savon # flip back to default Ruby rvm system
Cut Rubies with ease…










If you have problems installing Ruby versions you should check the troubleshooting guide of RVM.
I ran into some problems with an old version of readline installed via macports, which could be resolved with the help of the guide.
Awesome exposition on why you wanted to use RVM!
If you end up seeing `weird` make errors likely you need to install readline / openssl / iconv / whatever, please see here for more information:
http://rvm.beginrescueend.com/packages/
~Wayne
And don’t forget to install Xcode and the developer tools so that you got the compilers you need:
http://developer.apple.com/tools/xcode/
Pingback: Ruby in Java, Java in Ruby, JRuby or Ruby Java Bridge? | #nofail