Buidling a new Ruby 1.9 development stack on Ubuntu

I have written these notes as a record of my last Ruby development machine, build on top of Ubuntu 9.10 server. I use Ruby 1.9 exclusively, with no Rails, just pure Ruby.

Start by downloading the latest Ubuntu server image. I use the 64 bit version.

Start up your virtual machine manager (I use VMWare Fusion), and create a new machine with 5-6GBytes of disk space. I am not too worried about partitioning since this will not be a production machine. I don't need too much space since development of pure Ruby apps is not too space consuming. I also like the ability to quickly copy the VM from one computer to another, and creating lots of backup snapshots for not too much extra space.

Once the new VM is ready, boot into it and log one. First update the OS before adding the development stack.

Update the apt-get sources:

sudo apt-get update

Then the OS:

sudo apt-get dist-upgrade.

Now get the development tools and libraries:

sudo apt-get install build-essential

You will also need:

* The Zlib development headers:

sudo apt-get install zlib1g
sudo apt-get install zlib1g-dev

* The OpenSSL development headers:

sudo apt-get install libssl-dev

* The GNU Readline development headers:

sudo apt-get install libreadline5-dev

Now you are ready for Ruby itself. Get the source and expand the package:

wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p376.tar.gz
tar -xvzf ruby-1.9.1-p376.tar.gz

Enter the Ruby source code directory and configure, make, make install:

cd ruby-1.9.1-p376
./configure --prefix=/opt/ruby1.9 --program-suffix=1.9
sudo make
sudo make install

Add symlinks to access the Ruby binaries. Symlinks also make it easy to manage multiple versions of Ruby running on the same machine:

sudo ln -sf /opt/ruby1.9/bin/ruby1.9 /usr/local/bin/ruby
sudo ln -sf /opt/ruby1.9/bin/erb1.9 /usr/local/bin/erb
sudo ln -sf /opt/ruby1.9/bin/irb1.9 /usr/local/bin/irb
sudo ln -sf /opt/ruby1.9/bin/rdoc1.9 /usr/local/bin/rdoc
sudo ln -sf /opt/ruby1.9/bin/ri1.9 /usr/local/bin/ri
sudo ln -sf /opt/ruby1.9/bin/testrb1.9 /usr/local/bin/testrb
sudo ln -sf /opt/ruby1.9/bin/gem1.9 /usr/local/bin/gem

Almost done, just update Ruby gems, and your Ruby stack is ready, albeit at bare minimum level of functionality:

sudo gem update --system

Additional resources:

You will most likely need support for Git, and sqlite3 (at least for prototyping).

For Git, install the essentials, then get the source, enter its directory, configure, make it, and install it:

sudo apt-get build-dep git-core git-doc
wget http://kernel.org/pub/software/scm/git/git-1.6.6.tar.gz
tar -xvzf git-1.6.6.tar.gz
cd git-1.6.6
./configure
make prefix=/usr/local all doc
sudo make install install-doc

For Sqlite3, you will need the binary and the development sources:

sudo apt-get install sqlite3
sudo apt-get install libsqlite3-0 libsqlite3-dev

And finally get the Ruby gem:

sudo gem install sqlite3-ruby

Happy Ruby coding!

About

Twitter