I was installing Rubygems 1.2.0 on Ubuntu 7.04 on Friday, something I’ve done many times but for the first time I saw this error when I ran sudo ruby setup.rb
./lib/rubygems/spec_fetcher.rb:1:in `require': no such file to load -- zlib (LoadError) from ./lib/rubygems/spec_fetcher.rb:1 from ./lib/rubygems/source_index.rb:10:in `require' from ./lib/rubygems/source_index.rb:10 from ./lib/rubygems.rb:767:in `require' from ./lib/rubygems.rb:767 from setup.rb:22:in `require' from setup.rb:22
Having a look around the web yielded several approaches to solve the problem but no solution so I decided to build Zlib from source, then rebuild Ruby and then install Rubygems. That worked.
Here it is step by step.
I assume you already have the ruby and rubygems sources at this point.
- Change directory to wherever you keep source files. I use ~/src. Download and extract the Zlib source tarball to that directory.
cd ~/src wget http://www.zlib.net/zlib-1.2.3.tar.gz tar -xzf zlib-1.2.3.tar.gz - Build Zlib
cd ./zlib-1.2.3 ./configure make sudo make install - Rebuild ruby
cd ~/src/ruby-1.8.6-p114 ./configure make sudo make install - and finally install Rubygems
cd ~/src/rubygems-1.2.0 sudo ruby setup.rb
You should be up and running now.
December 3rd, 2008 at 5:37 am
Worked like a charm…Thanks!