These are instructions for building and installing a 64-bit version of Ruby, Rubygems and Ruby on Rails in the new Mac OS X 10.6 Snow Leopard.
The advantages of Ruby’s own build in
/usr/local
described
here and
here .
')
Requirements
Before you begin, make sure that you have all of the following:
- Mac OS X 10.6 Snow Leopard
- The latest version of Xcode Tools (from the Snow Leopard CD or from the Apple website - version 10.5 does not fit )
- Understanding of Unix basics and skills in the Terminal.
If you want to learn more about UNIX and the command line,
check out my Peepcode screencast on this topic.
Step 1: Set the PATH environment variable
Run Terminal.app from the
/Applications/Utilities
.
The first thing we do is set the PATH environment variable. It determines where the system is looking for the commands we enter. You will need to supplement it so that the jokes that we are going to install are visible to the system and the command line. Using any text editor, create and edit the
.profile
file in your home folder (note the "." At the beginning)
If you use
Textmate , you must have
the mate shell command installed , you can create and edit the file like this:
mate ~/.profile
At the end of the file, add the following line:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
Save and close the file, then run the following command to load the changes into the current shell session.
source ~/.profile
To make sure everything went as it should, enter the following command:
echo $PATH
You should see
/usr/local/bin
at the beginning of the line returned.
Step 2: Download
We will create a folder in which we put the files that we are going to download and install. If you want, this folder can be deleted at the end, but you can leave it - it will simplify the reinstallation or deletion, if you suddenly need it.
Making a folder:
mkdir ~/src
cd ~/src
Download Ruby and Rubygems:
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.gz
curl -O http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-1.3.5.tgz
Step 3: Build and Install
First Ruby:
tar xzvf ruby-1.8.7-p174.tar.gz
cd ruby-1.8.7-p174
./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
make
sudo make install
cd ..
To make sure everything is installed correctly and where necessary, type:
which ruby
You should see
/usr/local/bin/ruby
If so, then you now have a super-fast 64-bit Ruby and it is completely ready for work. If you see something else, then most likely you have installed the PATH incorrectly. Check if you did everything right in the first step and try again.
Build and install Rubygems:
tar xzvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo /usr/local/bin/ruby setup.rb
cd ..
Install Rails.
sudo gem install rails
If you are using MySQL, you can still install MySQL gem. To do this, you need to know where MySQL is installed. This is usually
/usr/local/mysql
. Then the installation of the heme will look something like this:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
Congratulations, you now have your own builds of fresh versions of Ruby, Rubygems and Rails installed, which do not conflict with the system versions. Hooray.