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
Matt
Mitchell
Abe
Todd
K
Jw
Ren
Rico
XRumerTest
XRumerTest
BrianPseup