Thursday, June 18, 2009

How to install ruby and related gems on Mac OS X (Leopard)

Ruby

Type these commands into Terminal:

curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
tar xzvf ruby-1.8.7-p72.tar.gz
cd ruby-1.8.7-p72
./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
make
sudo make install
cd ..


To verify that Ruby is installed and in your path, just type:

which ruby

You should see:

/usr/local/bin/ruby

RubyGems

After installing ruby, move on to ruby gems the same way:

curl -O http://rubyforge.iasi.roedu.net/files/rubygems/rubygems-1.3.1.tgz
tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo /usr/local/bin/ruby setup.rb
cd ..

Ruby on Rails and other gems

Now you are ready to install important gems:

sudo gem install rails

sudo gem install mysql

or do it in a single step like:

sudo gem install RedCloth termios rspec sake capistrano mongrel

Congratulations! You are done with the basic setup of ruby and rails.