Writing things down so I can remember them later

WaltCo Tech

My .vimrc file »

Installing Ruby and Ruby on Rails in Ubuntu 7.10 Gutsy Gibbon

December 24th, 2007 by Walter Wilfinger
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

tl;dr version

sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby
wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
tar xzvf rubygems-1.0.1.tgz
cd rubygems-1.0.1
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system
sudo gem install rails
sudo apt-get install build-essential ruby1.8-dev
sudo gem install mongrel
sudo apt-get install mysql-client mysql-admin mysql-query-browser libmysqlclient15-dev
sudo gem install mysql
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby
echo "export RUBYOPT=rubygems" >> ~/.profile
rails path/to/your/app

Coming from Gentoo, I thought installing anything on Ubuntu would be a breeze. Especially something with so much Internet-hype as Ruby on Rails. Unfortunately, the process isn’t completely intuitive. After breaking my teeth on my first few Ubuntu installs (sudo apt-get install vlc…wow that worked?), I was expecting something along the following to work for Rails:

sudo apt-get install ruby rubyonrails

At which point Ubuntu’s magical installer gnomes would pop a working installation of Rails onto my laptop.

This, to my dismay, was not the case. From what I can gather, this is because you want to use RubyGems to manage your Ruby…gems. Ubuntu, on the other hand, really wants to use Aptitude to manage your Ruby gems. It wants to do this so much, in fact, that if you install RubyGems using Aptitude pretty much nothing will work. You can work around this by installing RubyGems to your home directory. I tried out that method, but found sudo gems update –system calls would try to update to /usr/lib.

For those playing at home, /usr/lib is not your home directory.

I would expect the open source super-nerds to figure this out. Leaving me, being a dumb end-user, only to do a single apt-get command, make a cup of tea, and then while still waiting for the water to boil Rails would finish installing. I would come back to an impatient laptop who is wondering why I thought the whole process would take so long.

The open-source nerds have instead decided — as far as I can tell by this nerd fight from October of this year — to just bitch about who is putting what in the wrong place. This leaves us longing for a Rails install; and that cup of tea now that we mentioned it. Hold on one minute…

Mmmm. Chai tea. Ok. We’re going to install Ruby using apt-get. Then we will install RubyGems from source, forgoing Aptitude altogether.

Install Ruby using apt-get

sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby

I was expecting something simpler, say “ruby”, that would pull in all these packages into one. This package might exist, but the above is what I found referenced online.

Install RubyGems manually from source

In case this becomes outdated, you can get a link to the latest RubyGems tarball by visiting RubyForge here.

wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
tar xzvf rubygems-1.0.1.tgz
cd rubygems-1.0.1
sudo ruby setup.rb
# This creates /usr/bin/gem1.8, but every guide you find will just use "gem"
# so create a symbolic link
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
# update rubygems
sudo gem update --system

Now we’re in flavor country. Install Rails using RubyGems

sudo gem install rails

I hear Mongrel is cooler than WEBrick?

sudo apt-get install build-essential ruby1.8-dev
sudo gem install mongrel

Rails 2.0 uses SQLite3 as it’s default database now instead of MySQL

Note: Find any GUI database managers for SQLite
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby

If you still want to use MySQL

I install MySQL Query Browser and MySQL Admin as well in case things get a little too complicated.

sudo apt-get install mysql-client mysql-admin mysql-query-browser libmysqlclient15-dev
sudo gem install mysql

If you want to have RubyGems automatically loaded when you run ruby script.rb

I didn’t realize at first, but Rails handles loading up RubyGems’s library file rubygems.rb. That means if you want to use a Gem outside of Rails you have to do one of three things.1

  1. Call require ‘rubygems’ in every single script (bleh)
  2. Call the ruby interpreter with ruby -r rubygems script.rb or ruby -rubygems script.rb every time you want to run your script
  3. Add this environment variable to your shell RUBYOPTS=rubygems

The third option messes with your system the most, but it is also the laziest way to get things done. I went with it.

echo "export RUBYOPT=rubygems" >> ~/.profile #You'll have to log in/out to have this apply

Finally, create your new app

rails path/to/your/app

So much for quick and painless, eh?

Notes:
  1. http://docs.rubygems.org/read/chapter/3#page70 []
My .vimrc file »

11 Responses

  1. Riz Silverthorn Says:

    Just had to say thanks - I have been struggling with a borked install on Gutsy for a few days. I was getting the infamous GEMRunner error, and anything I was trying only seemed to make matters worse!

  2. David Salgado Says:

    Very helpful. Thank you.

  3. joe Says:

    oh god. i wish you posted your address so i could send you money.

    i’ve been dealing with this GEMRunner bs for days now.

    you are my god.

  4. Bring in the new year with Gutsy Gibbon, Parallels, Ruby, and Rails Says:

    […] Moving on to the ruby and rails installation. apt-get wants to manage all the packages it installs, so installing gem using apt-get won’t be feasible. Walter Wilfinger has posted complete instructions on how to get ruby and rails running in his post Installing Ruby and Ruby on Rails in Ubuntu 7.10 Gutsy Gibbon. […]

  5. lobo-tuerto Says:

    I just unistalled rubygems, because I had some problems mixing “gem update –system” and “apt-get install rubygems”.

    But even though I uninstalled it and reinstalled, the path for my gems got changed.

    When I reinstalled rubygems the directory for the gems was:
    /var/lib/gems/1.8

    And after some gem installs and some sudos (listed here) I opened another console windows and when typed “gem env” the directories where changed to:
    /usr/lib/ruby/gems/1.8

    Do you have any idea of what could be causing this?

    Any help will be appreciated.

  6. Cómo instalar Ruby, RubyGems y Rails en Ubuntu 7.10 Gutsy Gibbon | Lobo tuerto Says:

    […] Estuve buscando una guía definitiva para instalar Ruby y Ruby on Rails en Ubuntu 7.10, entre todas ellas la única que me funcionó a la perfección fue la escrita por Walter Wilfinger: Installing Ruby and Ruby on Rails in Ubuntu 7.10 Gutsy Gibbon. […]

  7. Lobo tuerto Says:

    The spanish version is done:
    http://lobotuerto.com/blog/2008/01/26/como-instalar-ruby-rubygems-y-rails-en-ubuntu-710-gutsy-gibbon/

    Take a look :)

  8. Chris B Says:

    Respect that man!!! Nice and easy to follow, and it actually made some sense to a ROR n00b. Cheers man!

  9. Ingy Says:

    beyond <3. <3 of galactic proportions.

  10. Let the log begin « Log of my ubuntu travails Says:

    […] Let the log begin Today, I installed ruby on rails on my Gutsy-Gibbon (Ubuntu 7.10) OS.  I followed these steps (which I swiped from an excellent posting by Walter Wilfinger): […]

  11. Antoine Says:

    Try

    sudo apt-get install ruby-full for the first line.

    sudo apt-cache showpkg ruby-full
    Package: ruby-full
    Versions:
    0.2 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_gutsy_universe_binary-i386_Packages) (/var/lib/dpkg/status)
    Description Language:
    File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_gutsy_universe_binary-i386_Packages
    MD5: d3a7d5918a0478f88f402f1b12575bee

    Reverse Depends:
    Dependencies:
    0.2 - ruby (0 (null)) irb (0 (null)) rdoc (0 (null)) ri (0 (null)) libdbm-ruby (0 (null)) libgdbm-ruby (0 (null)) libreadline-ruby (0 (null)) libopenssl-ruby (0 (null)) ruby1.8-dev (0 (null)) libtcltk-ruby (0 (null)) ruby-elisp (0 (null))
    Provides:
    0.2 -
    Reverse Provides:

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.