Playing with Ruby


This is a remake of Installing Rails 2 on Ubuntu but targeting Ruby in general and with some improvements. Essentially the same, actually, but more usable, at least for myself.

Ubuntu, like many other free operating systems, have a beautiful package management system that will track what depends on what, what is installed, what is not, what is not longer needed, which versions of each. If you tamper with it, you are asking for trouble. If you do a manual upgrade, from sources, eventually a package upgrade will downgrade your version or some other application being incompatible will not work. And once you start throwing files in /usr, you start to ask for trouble. I’ve been using this type of operating systems for years and I’ve learned this by experience.

Nevertheless you, as I, want to try and code with Rails 2, right? Or Merb? or any other Ruby softawer that hasen’t been packaged yet. Well, this is how I installed it in my Kubuntu box (should work the same for any Ubuntu and Debian derivate as well as others). I’ve decided to install everything on /opt/ruby. I like to keep more-or-less self-contained directories in /opt. So I started with:

$ sudo mkdir /opt/rails
$ sudo chown pupeno:pupeno /opt/rails

and that’s the last time I’ll ever use root access in this document, and that’s the way I like it. Another important detail is that I’ll keep all the environment and software entirely optional. All you’ll do here will be in a separate directory and will not interfere with the rest of your computer. Actually, to use it, you’ll have to load a file, which means, you control when you are entering the Ruby environment. In ~/bin/ I put:

#!/usr/bin/env bash


export PATH="$RUBY_PREFIX/bin:$RUBY_PREFIX/lib/ruby/gems/1.8/bin/:$PATH"
export MANPATH="$RUBY_PREFIX/share/man:$MANPATH"

PS1=" $PS1"


I started by installing Ruby itself. Maybe this wasn’t needed being that Ruby 1.8 is already available as a package, but I wanted a really clean and separated environment. I started downloading and unpacking ruby-1.8.6-p111.tar.gz:

$ wget
$ tar xvfz ruby-1.8.6-p111.tar.gz

and then the usual compile and installing (look ma! no root, no su, no sudo!):

$ cd ruby-1.8.6-p111/
$ ./configure --prefix=/opt/ruby/
$ make
$ make install

Time to enter the Ruby environment:

$ source ~/bin/
 $ which ruby
 $ ruby --version
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]

Good! To have a nice irb and actually be able to run the Rails’ console, we also need the readline gem:

 $ cd ext/readline
 $ ruby extconf.rb
 $ make
 $ make install


Installing rubygems is easy as well. We again start downloading and unpacking, this time, rubygems-1.0.1.tgz.

 $ wget
 $ tar xvfz rubygems-1.0.1.tgz

And now build and install:

 $ cd rubygems-1.0.1
 $ ruby setup.rb
Removing old RubyGems RDoc and ri...
Installing rubygems-1.0.1 ri into /opt/ruby//lib/ruby/gems/1.8/doc/rubygems-1.0.1/ri...
Installing rubygems-1.0.1 rdoc into /opt/ruby//lib/ruby/gems/1.8/doc/rubygems-1.0.1/rdoc...
As of RubyGems 0.8.0, library stubs are no longer needed.
Searching $LOAD_PATH for stubs to optionally delete (may take a while)...
No library stubs found.
  $ which gem
  $ gem --version


Rails and Merb

Just as explained on the Rails web site:

  $ gem install rails

or for Merb:

  $ gem install merb

And that’s it, you are ready to rail! or merb! (as you can see, all the magic is in that little file)

Leave a Reply

If you want to work with me or hire me? Contact me

You can follow me or connect with me:

Or get new content delivered directly to your inbox.

Join 5,038 other subscribers

I wrote a book:

Stack of copies of How to Hire and Manage Remote Teams

How to Hire and Manage Remote Teams, where I distill all the techniques I've been using to build and manage distributed teams for the past 10 years.

I write about:

announcement blogging book book review book reviews books building Sano Business C# Clojure ClojureScript Common Lisp database Debian Esperanto Git ham radio history idea Java Kubuntu Lisp management Non-Fiction OpenID programming Python Radio Society of Great Britain Rails rant re-frame release Ruby Ruby on Rails Sano science science fiction security self-help Star Trek technology Ubuntu web Windows WordPress

I've been writing for a while:


%d bloggers like this: