Ruby gem command install does not find zlib

Asked by Tommy Pollák

After reinstallation of Ubuntu 12.04 and Ruby with rbenv the gem command install does not find zlib

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

This is a well known problem due to missing libs, so I have installed them (zlib1g-dev, zlib1g, libssl-dev,
      libreadline-gplv2-dev, lib64readline-gplv2-dev) with sudo apt-get, removed Ruby and reinstalled 1.9.3-p286 but it does not work still.

More info

~$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [i686-linux]
  - INSTALLATION DIRECTORY: /home/user/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /home/user/.rbenv/versions/1.9.3-p286/bin/ruby
  - EXECUTABLE DIRECTORY: /home/user/.rbenv/versions/1.9.3-p286/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/user/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1
     - /home/user/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
~$

~$ echo $PATH
/home/user/.rbenv/shims:/home/user/.rbenv/bin:/home/user/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
~$

So, what is wrong?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu rubygems Edit question
Assignee:
No assignee Edit question
Solved by:
Tommy Pollák
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What is the output of:

lsb_release -a; uname -a; dpkg -l | grep zlib

thanks

Revision history for this message
Tommy Pollák (tpollak) said :
#2

~$ lsb_release -a; uname -a;dpkg -l | grep zlib
LSB Version: core-2.0-ia32:core-2.0-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:core-3.2-ia32:core-3.2-noarch:core-4.0-ia32:core-4.0-noarch
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise
Linux tpollak-XPS 3.2.0-32-generic-pae #51-Ubuntu SMP Wed Sep 26 21:54:23 UTC 2012 i686 i686 i386 GNU/Linux
ii zlib1g 1:1.2.3.4.dfsg-3ubuntu4 compression library - runtime
~$

OK?

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

Your output does not show zlib1g-dev !?!?!

Revision history for this message
Tommy Pollák (tpollak) said :
#4

Thanks, you are right. So I installed:

~$ sudo apt-get install zlib1g-dev
[sudo] password for user:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-29 linux-headers-3.2.0-29-generic-pae
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  zlib1g-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 162 kB of archives.
After this operation, 375 kB of additional disk space will be used.
Get:1 http://se.archive.ubuntu.com/ubuntu/ precise/main zlib1g-dev i386 1:1.2.3.4.dfsg-3ubuntu4 [162 kB]
Fetched 162 kB in 0s (729 kB/s)
Selecting previously unselected package zlib1g-dev.
(Reading database ... 181624 files and directories currently installed.)
Unpacking zlib1g-dev (from .../zlib1g-dev_1%3a1.2.3.4.dfsg-3ubuntu4_i386.deb) ...
Processing triggers for man-db ...
Setting up zlib1g-dev (1:1.2.3.4.dfsg-3ubuntu4) ...

but it did not help

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

Is it necessary to remove Ruby and reinstall it again?

Revision history for this message
Tommy Pollák (tpollak) said :
#5

Yes! After
rbenv uninstall 1.9.3-p286
rbenv install 1.9.3-p286

gem install rails

worked!