Ruby errors on CentOS 5.2

I recently needed to setup a Ruby on Rails server for one of our developers. Since he's usually setup his own Ruby environments in the past, this was a new procedure for me. Errors and troubles always come with learning something new and I was getting a "ruby no such file to load -- zlib (LoadError)" message when installing rubygems. I also encountered a "no such file to load -- openssl" when trying to start the rails server.

Because of a version dependancy, I had to install Ruby from source (1.8.7) and not from RPM (1.8.5). The error suggests that I'm missing a required zlib dependancy. So I double checked that I had zlib installed by "rpm -qa |grep zlip" and got back that both the zlib & zlib-devel packages were installed.

By the saving grace of google, I came across a blog post by Lucas Chan outlining the problem.

I followed what he said by:

#######
# cd /path_to_ruby_src/ext/zlib/
# ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
# make
# make install
#######

Then I was able to run the ruby gem setup:

######
# /path_to_rubygems_src/ruby setup.rb
######

Thanks Lucas. I'm hoping that others may find this or your post in the future.

Edit:
After getting rails installed I create my first application and tried to start it with:

#/path_to_app/script/server

but got back an error "no such file to load -- openssl". I know I had openssl installed on the server but it turns out I forgor the openssl-devel package. I used yum and downloaded the package and dependancies but still was getting the error. To fix, you have to recompile from scratch OR just do:

# cd /path_to_ruby_src/ext/openssl/
# ruby extconf.rb
# make
# make install

That process actually only recompiles the necessary component. After that the application started up successfully.
# /path

No votes yet