[RVM][Ruby] ERROR: Loading command: install (LoadError) cannot load such file -- zlib, ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand

Tadashi Shigeoka ·  Thu, February 9, 2012

After setting up a Ruby development environment on Mac with RVM, an error occurred when I tried to install a gem.

■ Error Content

$ gem install heroku
ERROR:  Loading command: install (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

It seems the cause was installing Ruby with the following command, which didn’t properly set the path to zlib.

rvm install 1.9.3 -C \\
--with-readline-dir=$rvm_path/usr \\
--with-iconv-dir=$rvm_path/usr \\
--with-zlib-dir=$rvm_path/usr \\
--with-openssl-dir=$rvm_path/usr

It worked well when I installed simply without specifying paths with the -C option.

rvm install 1.9.3

I don’t fully understand the cause, but I’ll consider it good for now.

That’s all from the Gemba.