Ruby on Rails installation on CentOS 5.2 – zlib and other errors January 6, 2009 at 9:59 pm

I thought it would be good to share my experience with installing Ruby on Rails w/ CentOS 5.2.

It didn’t get off to a very good start, namely because the person before me had already tried to install rails unsuccessfully. The issue appears to stem from the configure mechanism in Ruby which links against zlib libraries that may or may not be correct. Undoing this was non-trivial.

Specifically I was receiving this error when doing anything with gem:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require': no such file to load -- zlib (LoadError)

Installing zlib and zlib-devel libraries on CentOS did not fix the problem because the linking had already occurred back in the ruby build (I think, anyway). I decided the easiest thing was to do a “rip and replace” fix by ripping out all of ruby and the associate gem software and re-installing. I did this as follows:

1. Remove all packages that were installed via yum

rpm -qa | grep ruby
yum remove [insert results from output above here]

2. Go look for remnants that may have been installed by gem or by a manual compile of ruby and remove them, too. A few places I had to look:

rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem

3. Download the latest ruby source and rubygems source to /usr/local/src/ and extract them. At the time of this writing, those commands were:

cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
tar xzf ruby-1.8.7-p72.tar.gz
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzf rubygems-1.3.1.tgz

4. Go into the Ruby directory and compile it, like so:
cd ruby-1.8.7-p72
./configure
make

NOTE: This was the key part to watch. This time around, you should see compile messages stating that zlib was compiled successfully at the end of the log on your screen.

5. Now install Ruby, if all went well:

make install

6. Now go setup RubyGems, like so:

cd ../rubygems-1.3.1
ruby setup.rb

7. Update the gem system for good measure

gem update --system

7. Install Rails

gem install rails

Presto, a nice clean CentOS 5.2 install.

2 Responses to “Ruby on Rails installation on CentOS 5.2 – zlib and other errors”

  1. […] having a server that’s ready for anything! If you want to know how to install Ruby on CentOS, check out this person’s article. Did upgrading ruby help at all? Not at all, but now I had a fully functional version of Ruby on […]

  2. […] having a server that’s ready for anything! If you want to know how to install Ruby on CentOS, check out this person’s article. Did upgrading ruby help at all? Not at all, but now I had a fully functional version of Ruby on […]

Leave a Reply

You must be logged in to post a comment.