Ruby On Rails in Debain/Ubuntu and missing zlib

There is a known problem with ruby on Debian or Ubuntu with gem command not working properly.  Here is how to fix it.

So here is how to install RoR from source:

user@computer:$ cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.gz
tar -zxf ruby-1.8.7-p299.tar.gz
cd ruby-1.8.7-p299
./configure
make
make install
cd ..

install ruby gems

user@computer:$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar -zxf rubygems-1.3.7.tgz
cd rubygems-1.3.7
ruby setup.rb
cd ..
gem install rails

When you try to use gem command you will see something like this:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load — zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:1
….

The solution is described on lots of website on the internet:

user@computer:$ wget http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz
tar xvzf ruby-zlib-0.6.0.tar.gz
cd ruby-zlib-0.6.0
ruby extconf.rb
make
make install

If ruby extconf.rb fails, try to install zlib1g-dev package via apt.

Finally install rails

user@computer:$ gem install rails

However I have only found one website to be refered as a source for missing lib: http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz which didn’t work when I needed this file. I thought it’s a good idea to serve this file here.

ruby-zlib-0.6.0.tar

If you see following error:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load — openssl (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from /usr/local/lib/ruby/gems/1.8/gems/puppet-2.6.0/lib/puppet/ssl.rb:3

Fix it by:

user@computer:$ cd /usr/local/src/ruby-1.8.7-p299/ext/openssl/
ruby extconf.rb
make
make install

On Lenny you need libssl-dev package installed to do this.

Share on TwitterShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  • http://www.avidimages.net Val

    Thanks dude, i was about to tear my hair out but this worked spot on :)