Installing Ruby on Rails on Debian Lenny

Last night i severely messed up my computer trying to install the latest version of CouchDB. I ran into dependency troubles, and then i uninstalled some kind of essential packages that ended up removing all sorts of things that i rather wanted! But this is okay because i needed a push to move up to the new Debian. And i'm glad i did … Lenny looks nice so far! :)

So i am currently going through the process of installing Ruby on Rails. I've never managed to do this right first time, but i always learn a little bit more every time i try. Let's see if i can nail it this time.

Essential things

I totally wiped the hard drive because it was in such a mess, so i'm going to need some basic stuff like the GNU C Compiler and the 'make' tool.

sudo apt-get install gcc make

OpenSSL

In my experience, you must have OpenSSL installed. Other peoples experiences may vary. I download the source code from openssl.org/source and build it like this:

./configure
make
make test
sudo make install

The 'make test' is well worth running – it performs loads of checks!

Ruby

Always check rubyonrails.org/down for the recommended version of Ruby. Never install Ruby via apt-get … you may get an incompatible version, and it will likely install it to a weird place. It just makes things messy. Download it, unzip and install like this:

./configure
make
make test
sudo make install

Test that you got it successfully:

ruby --version
ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-linux]

Zlib

Bogdan advises me that the following Zlib steps may be necessary. I have not tested these, but i know i've had problems with Zlib in the past, so i think it's likely that this is a good tip:

Install the development libraries:

apt-get install zlib1g-dev

Install Zlib for Ruby:

wget http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz
tar zxf ruby-zlib-0.6.0.tar.gz
cd ruby-zlib-0.6.0
ruby extconf.rb
make
sudo make install

Gems

Similarly, check the Rails download page to see where to download Gems. I think it's okay to just get the latest version. Unzip, go into the directory, and use Ruby to install Rubygems.

sudo ruby setup.rb

Again, it's sensible to check:

gem --version
1.2.0

More than anything, this reassures me that 'gem' got into the classpath.

Rails

If Ruby and Gems successfully installed, this bit should be easy.

sudo gem install rails

And that's it! Oh yeah, of course you could check the install with

rails --version
Rails 2.1.1

Woohoo! And also useful:

gem list
*** LOCAL GEMS ***
actionmailer (2.1.1)
actionpack (2.1.1)
activerecord (2.1.1)
activeresource (2.1.1)
activesupport (2.1.1)
rails (2.1.1)
rake (0.8.2)

SQLite3

Update to add: i just figured out how to get SQLite going on Debian. Download the source from here, compile and install, then:

sudo gem install sqlite3-ruby
Posted: September 14th, 2008
Categories: computer, ruby on rails
Comments: View Comments.
  • HBC
    WOW, thank you so much.. Ruby now installed and working :)
  • After spending half a day fooling around with apt-get in my attempt to install Ruby, and I can't tell you how happy I was to have found this post! Straight through, and now I'm ready to learn Ruby!
  • The way of installing Ruby is tough for me. It caused lot of problems for me. But this helps me a lot. Thanks.

    Regards.
  • Thank you so much for this tutorial, I've been having trouble for a while, but now it works perfectly after following your guide.
  • dvd436
    OMG OMG so pleased to have found this post. I have been looking for a way to install Ruby for ages now!

    Kudos to you!
  • Excellent post, it reallt helped me a lot


    IRSBlogger
  • Dear IRSBlogger,

    glad to hear it.
  • Great post, really help me alot. Thanks.

    Cheers,
    jana duit
  • scafativ
    After spending half a day fooling around with apt-get in my attempt to install Ruby, and I can't tell you how happy I was to have found this post! Straight through, and now I'm ready to learn Ruby!
  • I'm on the same boat, google rules! lol
  • I am glad you found it helpful! Have fun learning Ruby; it's a great language!
  • Bogdan
    This didnt work on my system because of missing zlib - here is the added step between ruby and gems

    MAKE SURE THAT ZLIB DEV LIBRARIES ARE INSTALLED BEFORE ANY RUBY INSTALLTING BY DOING

    apt-get install zlib1g-dev

    THEN continue with open ssl and ruby configure and such


    wget http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz
    tar zxf ruby-zlib-0.6.0.tar.gz
    cd ruby-zlib-0.6.0
    ruby extconf.rb
    make
    make install

    then continue on to the gem install :)

    Happy Rubying
  • Thank you very much - i will add your tips to the blog post.
blog comments powered by Disqus