David keeps yapping about his Ruby on Rails framework, and I have to admit it looks interesting.
So I decided to give it a shot, and see what all the fuzz was about. After all I only had to install 3 things:
But oh boy, had I known the difficulties I was setting myself up for and I probably wouldn’t have…
I have a machine running Debian that I use as my playground for this kind of thing. It was originally just running Apache 1.3 and not much else. The goal was to go from a that “blank” Debian installation to running Ruby on Rails (rubygem version) with a PostgreSQL database backend.
From the beginning I insisted on using apt-get as much as possible since I am Linux-n00b and prefer to stay away from configure and make. Blame my Windows heritage.
Even though this is written in guide/howto-form, it probably should not be taken as such. I am much too inexperienced around this (Debian and Ruby) to actually write a guide. This is merely what worked (and in particular, didn’t work) for me on my installation, if it turns out to work for you too, great! If not, well, too bad…
The stable Debian packages contains an old distribution of Ruby (v1.6.7) which won’t cut it for Gems nor Rails. We have to upgrade to the testing packages:
Edit /etc/apt/sources.list and added the following line:
deb http://http.us.debian.org/debian testing main contrib non-free
Refresh your local package lists:
root@mental$ apt-get update
And you should be about ready to continue. You may have to upgrade a whole bunch of your software at this point.
Consulting the Rails documentation it turns out installing Ruby-1.8 on it’s own isn’t enough. Ruby is fragmented into a gazillion different packages, but the following should get and install all that’s needed:
apt-get install irb1.8 libbigdecimal-ruby1.8 libcurses-ruby1.8 libdbm-ruby1.8 libdl-ruby1.8 libdrb-ruby1.8 liberb-ruby1.8 libgdbm-ruby1.8 libiconv-ruby1.8 libopenssl-ruby1.8 libpty-ruby1.8 libracc-runtime-ruby1.8 libreadline-ruby1.8 librexml-ruby1.8 libruby1.8 libruby1.8-dbg libsdbm-ruby1.8 libsoap-ruby1.8 libstrscan-ruby1.8 libsyslog-ruby1.8 libtcltk-ruby1.8 libtest-unit-ruby1.8 libtk-ruby1.8 libwebrick-ruby1.8 libxmlrpc-ruby1.8 libyaml-ruby1.8 libzlib-ruby1.8 rdoc1.8 ri1.8 ruby1.8 ruby1.8-dev ruby1.8-elisp ruby1.8-examples libpgsql-ruby1.8
After this, Ruby should work:
jcop@mental$ ruby1.8 -v
ruby 1.8.2 (2004-11-23) [i386-linux]
… almost work, at least.
It turns out the Ruby testing package doesn’t contain the zlib library for Ruby, so you have to install this manually. No problem, it’s just a matter of downloading it followed by
tar -zxvf ruby-zlib-0.6.0.tar.gz<br />
cd ruby-zlib-0.6.0<br />
/usr/bin/ruby1.8 extconf.rb<br />
make install<br />
Assuming you already have zlib installed you are now ready to install RubyGems
wget http://rubyforge.org/frs/download.php/1399/rubygems-0.8.1.tgz
tar -zxvf rubygems-0.8.1.tgz
cd rubygems-0.8.1
ruby1.8 install.rb
Simple, huh? Yup, but not quite…
It turns out there is a problem with running RubyGems on Ruby 1.8.2. Basically it’ll give you an error (“string contains null byte”) or something to that effect whenever you try to install a gem.
Since apt-get won’t give us Ruby 1.8.1 and I want to use apt and RubyGems I was stuck at this point for a while, while trying out different workarounds to no avail and becoming increasingly frustrated.
#rubyonrails to the rescue! Apply this patch to RubyGems, and your worries disappear.
gem install rails
Voila… almost…
Due to us running Ruby 1.8.2, which is an unstable CVS checkout as far as I can gather we need to have this patch applied.
After this, you should be able to take on the tutorial from around step 2.
See, it wasn’t that bad…
I would have liked to read this log last week where i ran into the same problem whit ruby 1.8.2 (2004-11-23).
I found an other way to solve the problem than using the patch.
It is possible, to install ruby 1.8.2 (2004-11-03), and because i have installed it perviously on my Linux box all the install packages I needed was
in /var/cache/apt/archives. But u can also download them an install the previous ruby unstable packages with
dpkg -i
The problem is not in gem but in a known bug in Dir.glob. I hope that it will be fix soon.
An easier way of installing ruby1.8 on a debian stable system is to add
a backport to the /etc/apt/sources.list file, suche as this:
deb http://people.debian.org/~angdraug/ stable local
deb-src http://people.debian.org/~angdraug/ stable local
This allows you to install just the ruby-related stuff, compiled for
debian stable, without needing to install a whole lot of other stuff
you don't need.
To clarify, it's Debian that split the ruby packages up, not the Ruby
team. (I still can't understand why Linux distros insist on having a
foo and foo-devel package, how big are a few include files for crying
out loud)..
For the installation of the zlib library, if you follow debian test, you can do apt-get install libzlib-ruby.
easy going...