Ruby 1.9 and Rails 3 on Mac OSX 10.5

Macs come with Ruby and Rails installed by default. However, the versions shipped are often older versions, and you are pretty much pegged to Apple's upgrade cycle. For example, my completely up to date Mac OSX 10.5.8 install is running ruby 1.8.6, gem 1.0.1 and rails 1.2.6.

The goal is to leave the system default versions in place and untouched. Lucky for us wayneeseguin has provided the world with a nifty piece of software called Ruby Version Management (RVM) that allows you to easily install multiple versions of ruby on a machine and let you choose between which version to run at any given point in time. Since each version runs within it's own environment you are then free to install (via gems) whatever you need.

To use RVM on Mac OSX 10.5.8 you will need to install Xcode 3.1.4 Developer Tools. DO NOT install the latest version as it will only run on Mac OSX 10.6. You can find the Xcode Developer Tools after creating an account on the Apple membership site.

Here are the steps I took to get ruby 1.9.2, gem 1.3.7 and rails 3.0.0 up and running.

Prepare a workspace

When installing or upgrading software I usually create a working directory to contain all of the related bits-n-pieces. That way I know what to uninstall if I want to roll back ;-)

mkdir -pv ~/workspace/rails3

cd  ~/workspace/rails3

At the beginning of each of the following steps please ensure you are back in the root of your workspace.

SQLite3 Upgrade

First of all if you use SQLIte3 then you will need to upgrade the one that comes pre-installed as it is too old and crusty to be of use with Rails 3.

wget http://www.sqlite.org/sqlite-amalgamation-3.6.22.tar.gz

tar xvzf sqlite-amalgamation-3.6.22.tar.gz

cd sqlite-3.6.22/

./configure

make

sudo make install

sqlite3 --version # Confirm the correct version has been installed

Install RVM

The following steps are pretty straight forward and are taken from the RVM site.

curl http://rvm.beginrescueend.com/releases/rvm-install-head > rvm-install-head

chmod +x  rvm-install-head

./rvm-install-head

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" ' >> ~/.profile

source ~/.profile

Install Ruby

This step will install ruby 1.9.2 and set it to the default (for the current user only).

rvm install 1.9.2 -C --enable-shared,--with-readline-dir=/usr/local

rvm 1.9.2 --default

ruby -v # Confirm ruby version is correct

gem -v # Confirm gem version is correct

Install sqlite3-ruby

This is optional, but if you upgraded SQLite3 above then chances are good that you will want to do this step as well.

gem install sqlite3-ruby

Install Rails 3

You can explicitly install Rails 3, however since it has been released it will now be the default version installed when running the following command.

gem install rails

rails -v  # Confirm rails version is correct

Switching between ruby versions

The current user should now have ruby 1.9.2, gem 1.3.7 and rails 3.0.0 up and running. If you want to switch back to the system version then:

rvm system

tags: Mac, Ruby, Ruby on Rails, rvm

Sat 25 Sep 2010, 21:32

11 comments

This was helpful, thank you.

Matt

Thanks very much for taking the time to write this.

Mitchell

This is a life saver! Thank you for writing this. One quick add, someone people might need to get "git" from rvm steps.

Abe

Thanks for this post! I was able to get Rails 3.0 running on my 10.5.8 based Mac thanks to this. Much appreciated. I had to do this curl -O http://www.sqlite.org/sqlite-amalgamation-3.6.22.tar.gz instead of a wget

Todd

Thanks very much for the walkthrough , it is extremely useful

K

Thanks!!! I had a ridiculous time with this until I read your post. Works perfect now on my PPC!

Jw

What an adventure. I had to sidestep your tutorial to update BASH (install MacPorts). Then I came back and it all worked out. Merci beaucoup!

Ren

RVM Install doesn't seem to want to work. Script error.

Rico

Hello. And Bye.

XRumerTest

Hello. And Bye.

XRumerTest

For decades, Wunsiedel, a German town near the Czech border, has struggled with a parade of unwanted visitors. It is the birthplace of one of Adolf Hitler’s deputies, a man named Rudolf Hess. And every year, to residents’ chagrin, neo-Nazis marched to his grave site there.

BrianPseup

Back