Search code examples
ruby-on-railsrubygemsrbenv

Unable to install gems with rbenv


rbenv

$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ gem -v
1.8.23

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

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

I spent hours looking for answers...

Also installed zlib1g-devel but still cant install rails..


Solution

  • It's clearly telling you that you don't have zlib:

    cannot load such file -- zlib
    

    You haven't provided any details to what system you are running.

    sudo apt-get install zlib1g-dev
    

    or

    sudo yum install zlib-devel
    

    for red hat/centos/ubuntu systems. You'll then have to reinstall ruby. You may have some other dependencies and might need libyaml-dev or openssl.