Mar 23, 2009

Rails Development On Ubuntu

There's no shortage of posts on the web describing how to setup Ubuntu for Rails development but I'm going to add one more anyway. I choose to write this because none of the posts I ran across were geared towards a current Rails, RSpec, Cucumber, Git setup.

I'm using Ubuntu 9.04 (JauntyJackalope) during this installation.

First install Ruby and it's associated packages.

sudo apt-get install ruby-full

Next install the native SQlite3 libraries and command line tools.
sudo apt-get install sqlite3 libsqlite3-dev

Next install some native xml processing libraries used by webrat.
sudo apt-get install libxml2-dev libxslt-dev

Next install Git
sudo apt-get install git-core

Next install the tools necessary to build native rubygem extensions.
sudo apt-get install ruby-dev build-essential

Next install RubyGems from source because the Ubuntu packages are usually not current. I also prefer to install RubyGems into my $HOME directory because mixing source packages in with distribution managed packages is generally a bad idea.
wget -c http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xvzf rubygems-1.3.1
cd rubygems-1.3.1
ruby setup.rb --prefix=$HOME/.rubygems --no-format-executable

Once that's done you need to set some environment variables so that; Ruby can find the gems library, RubyGems can find the gem repository and executable gems will be in the $PATH. Add the following to the file $HOME/.bashrc
export RUBYLIB=$HOME/.rubygems/lib
export GEM_HOME=$HOME/.rubygems/gems
export PATH=$HOME/.rubygems/bin:$GEM_HOME/bin:$PATH

Then make sure the RubyGems library is up-to-date and install all the necessary gems.
gem update --system
gem install rake rails rspec-rails cucumber webrat sqlite3-ruby

If you want to double check your installation you can try the following...
ruby --version
gem --version
rails --version
spec --version
cucumber --version

3 comments:

Anonymous said...

the line:
# in $HOME/.bashrc
produces an error and can go no further.

Unknown said...

That line is a comment. It simply meant to add the following lines in the file "$HOME/.bashrc"

mdgrech said...

Awesome work, I'm going to bookmark this for sure. It has everything you could ever need to develop awesome sites.