RVM Ruby 1.9.1 install can't locate zlib but its runtime and dev library are there

Use rvm to install zlib

https://rvm.io/packages/zlib/

rvm package install zlib
rvm remove 1.9.1
rvm install 1.9.1 -C --with-zlib-dir=$rvm_path/usr

Edit: The rvm package command was renamed to rvm pkg in v1.6.25.


You need to install zlib before compiling/installing Ruby. If you didn't do this, make sure to remove everything related to Ruby 1.9.1 from your ~/.rvm folder (so that it will be build from scratch).

Install zlib using your favorite package manager:

sudo apt-get install zlib1g-dev

You might also want to install the following packages as they are required by tools like OpenSSL,
Nokogiri, IRB or SQLite:

 libssl-dev libreadline6-dev libxml2-dev libsqlite3-dev

Then install Ruby 1.9.1 again (nowadays I would suggest to use a newer version):

rvm install 1.9.1

Watch for "compiling ...". This should take a while. If it doesn't, then Ruby 1.9.1 might still be cached
in your ~/.rvm folder.


I encountered this problem when trying to:

gem install gruff

What actually worked for me (Ubunut 10.10, ruby MRI 1.8.7) is:

  • reading the rvm notes and installing the dependencies for my ruby version

sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf

  • then following closely the steps described in https://rvm.io/packages/zlib/
  1. rvm package install zlib
  2. rvm remove 1.8.7
  3. rvm install 1.8.7

So basically: just follow the rvm manual