After a couple of weeks of getting to know Mac OS X I finally decided to install the ruby on rails development environment. I found some of the guides out there a bit flakey so I have compiled this guide for dummies. I wont go as far as to install MySQL on this occasion but may do so if anyone would like to see that in the future. Another topic that I might cover will be the installation of Apache and Mongrel as a replacement for the default webrick server which ships as a development application server with the rails framework. For now your getting how to install ruby on rails!
The first step is to take a visit to the Apple developer’s website where with a small search you will find a download for ‘XCode‘ This is a pretty hefty download (around 200 MB) so if you’re on a dialup connection, forget it.
The next step in this fairly painless process is to setup your system paths. This is is also pretty straight forward. Open up a terminal window and type in the following commands.
touch .bash_profile
sudo open .bash_profile – at this point you might be asked to enter in your admin password.
You will now be presented with your profiles file. This is where you can setup your sytem’s paths. Add the following line into this file.
export PATH=”/usr/local/bin:/usr/local/mysql/bin:/usr/local/sbin:$PATH”
Easy stuff so far eh? Save this file and then close it down. The next step is to download a few packages which are going to allow us to turn your Mac into a Ruby on rails environment.
Download Readline , Ruby and finally ruby gems. Save them all to your desktop and extract them there.
We will now copy these files into a more appropriate directory. Follow these commands to do so:
sudo mkdir -p /usr/local/src
sudo chgrp admin /usr/local/src
sudo chmod -R 775 /usr/local/src
Now copy the files into the directory you have just created(your file names may be different depending on the versions you download):
mv ~/Desktop/readline-5.2 /usr/local/src/readline-5.2
mv ~/Desktop/ruby-1.8.6 /usr/local/src/ruby-1.8.6
mv ~/Desktop/rubygems-0.9.2 /usr/local/src/rubygems-0.9.2
The next phase of our mission is to install Readline. The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands.
Use the following commands to install it:
cd /usr/local/src/readline-5.2
./configure –prefix=/usr/local
make
sudo make install
Now we need to install ruby. I dont think I need to go into any detail on the ruby language. If you’re installing it, Im going to assume that you have some knowledge of it already. All I’ll say is that it is superb
Assuming you have been able to take care of the above commands then fire off the following commands in your terminal to install it:
cd /usr/local/src/ruby-1.8.6
./configure –prefix=/usr/local –enable-pthread –with-readline-dir=/usr/local
make
sudo make install
sudo make install-doc
The next stage is to install ruby gems:
cd /usr/local/src/rubygems-0.9.2
sudo /usr/local/bin/ruby setup.rb
sudo gem update –system
Almost there. The last step is to install the rails framework on top of what we have so easily done so far:
sudo gem install rails –include-dependencies
That’s it!!!! All thats left to do is check that we have install them properly and that they work.
type:
ruby -v
If you get a response with the version of ruby installed then you have installed ruby.
type:
rails -v
As above, if you get a response then you have come a long way in your quest of developing your first rails application.