Installing Ruby 1.9 on Mac OSX
Wed Jan 16 12:25:07 -0800 2008
If you have ruby and a mac, no doubt you want to try out 1.9 – but be warned, some things can break! This little tutorial shows you how to install Ruby 1.9 in parallel to your 1.8.x installation… which can be handy…
Especially useful if you are developing an application in Ruby and want to test against 1.8.x and 1.9.
The goal here is to end up with a set of tools that can be 1.8 or 1.9 at will. The way I will do it is that you will end up with “ruby” and “irb” and “rake” and “gem” all pointing to your existing version of Ruby (be that 1.8.6 or 1.8.5 or whatever). Then you will get another set of tools like “ruby-trunk”, “irb-trunk”, “rake-trunk” and “gem-trunk” that will point to the 1.9 versions of these programs.
So, sound good? Great, enough talk, lets get started.
Getting Ruby
You can download Ruby 1.9 from http://www.ruby-lang.org/en/downloads/
Getting Read Line
You will most likely need Read Line 5.2 (Ruby 1.9 needs it), so you can get it from the readline GNU page
Installing ReadLine
Do the following from your home directory:
baci:~ mikel$ tar xvzf readline-5.2.tar.gz baci:~ mikel$ cd readline-5.2 baci:~/readline-5.2 mikel$ ./configure --prefix=/usr/local/ baci:~/readline-5.2 mikel$ make baci:~/readline-5.2 mikel$ sudo make install
This will make and install Read Line for you.
But if you are on Leopard, this might not work as planned, so replace the “make” above with:
baci:~/readline-5.2 mikel$ make static baci:~/readline-5.2 mikel$ sudo make install-static
Thanks to Sean’s webblog for this tip.
Installing Ruby 1.9
Now you need to get Ruby working, you do this by doing the following:
baci:~ mikel$ tar xvzf ruby-1.9.0-0.tar.gz baci:~ mikel$ cd ruby-1.9.0-0 baci:~/ruby-1.9.0-0 mikel$ ./configure --program-suffix=-trunk --with-readline-dir=/usr/local baci:~/ruby-1.9.0-0 mikel$ make baci:~/ruby-1.9.0-0 mikel$ sudo make install
Note the ./configure step? This is important because you are passing in two options, firstly you are telling it to add -trunk to the end of each program it makes (you could put anything you want here basically) and secondly you are telling it where to get ReadLine from on the system.
And that’s it!
To test, just try typing:
baci:~ mikel$ irb-trunk irb(main):001:0> RUBY_VERSION => "1.9.0"
Enjoy!
blogLater
Mikel

Fri Feb 01 10:42:06 -0800 2008
Thanks Mikel!
This was the info I needed (for 10.4 Tiger). Cool
Cheers! sinclair
Fri Mar 07 03:10:54 -0800 2008
I needed to follow these steps on 10.5 leopard to get ruby 1.8.6-p114 to install properly with support for irb. Thanks for the steps to get me through it.
-Nick
Fri Apr 18 04:35:40 -0700 2008
in the readline ./configure, I think you should leave the trailing / off from /usr/local
also, do you need to make install for Ruby too?
and for Leopard, you might need a fix for readline? http://www.ruby-forum.com/topic/140471
Sat Jan 31 14:17:24 -0800 2009
you guys also might want to take a look at the ruby one-click installer for osx: http://rubyosx.com
we are currently preparing binaries for leopard, tiger and panther for the stable ruby 1.9.1-p0
Fri Feb 27 03:41:35 -0800 2009
If you have MacPorts, just type:
sudo port install ruby19
And go get a drink like the lazy ass you are. When you return, it’ll have downloaded, compiled, and installed Readline for you, and then done the same for Ruby. (Updates to either are just as easy.)
The only gotcha is it installs into the MacPorts directory /opt/local/bin, while the standard Ruby location is /usr/bin. If you want to put it there and make it the standard Ruby version for your mac, add the following:
cd /usr/bin sudo ln -s /opt/local/bin/ruby1.9 . sudo mv ruby ruby1.8 sudo ln -s ruby1.9 ruby
Done!
Fri Feb 27 03:51:37 -0800 2009
Ack, it mangled my last lines! Here’s the four commands to then make 1.9 standard on your mac:
cd /usr/bin
sudo ln -s /opt/local/bin/ruby1.9 .
sudo mv ruby ruby1.8
sudo ln -s ruby1.9 ruby
Fri Feb 27 03:55:53 -0800 2009
You might want to put the new irb in /usr/bin too…
cd /usr/bin
sudo ln -s /opt/local/bin/irb1.9 .
sudo mv irb irb1.8
sudo ln -s ruby1.9 irb
Thu Mar 19 13:45:36 -0700 2009
Thanks for the tips Rich, they were very helpful. The last line in your above post should read
sudo ln -s irb1.9 irb
otherwise…
Thu Mar 19 13:53:28 -0700 2009
Thanks for the tips Rich, they were very helpful. The last line in your above post should read
sudo ln -s irb1.9 irb
otherwise…
Thu Jun 11 13:36:55 -0700 2009
Hmmm I followed these instructions exactly and now I get “ruby: command not found”
ls -la /usr/bin/ruby* ruby -> ruby1.9 ruby1.8 -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby ruby1.9 -> /opt/local/bin/ruby1.9
what is up with that?
Thu Jun 11 13:54:57 -0700 2009
Figured it out, the original article is missing sudo make install
I ran that and now all is well.
Fri Jul 03 23:28:23 -0700 2009
Thanks Chris, good catch, fixed it in the article.
Thu Feb 04 19:31:27 -0800 2010
Hi..
I tried installing it on mac osx 10.5 but i am getting an error when i try installing ruby and run the make command.
I then get an error in the next make install command also and irb trunk then doesnt exist.
Could you please help me out?