SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Saturday, February 4, 2012

cannot load such file -- zlib

While installing rails 3.2 via rbenv, i stuck up with this error.

gem install rails -v=3.2

/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
ERROR:  Loading command: install (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

$ sudo apt-get install libyaml-dev 
$ sudo apt-get install zlib1g-dev

Now compile the zlib from the ruby versions directory
$~/.rbenv/versions/ruby-1.9.3-p0/ext/zlib$
sudo ruby extconf.rb
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for kind of operating system... Unix
checking for crc32_combine() in zlib.h... yes
checking for adler32_combine() in zlib.h... yes
creating Makefile

sudo make
sudo make install

Once again configure the ruby source
cd  ~/.rbenv/versions/ruby-1.9.3-p0/
./configure --prefix=$HOME/.rbenv/versions/ruby-1.9.3-p0
sudo make
sudo make install

Now i am able to install rails 3.2 versions