Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
660 views
in Technique[技术] by (71.8m points)

ruby - cannot load such file -- zlib even after using rvm pkg install zlib

I installed zlib package and ruby 1.9.3 using rvm, but whenever I try to install gems it says cannot load such file -- zlib

The commands I used to install are

$ rvm install 1.9.3
$ rvm pkg install zlib

$ rvm reinstall 1.9.3 --with-readline-dir=/home/username/.rvm/usr 
    --with-iconv-dir=/home/username/.rvm/usr 
    --with-zlib-dir=/home/username/.rvm/usr 
    --with-openssl-dir=/home/username/.rvm/usr

$ rvm use 1.9.3

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

All the help on this subject tells me to just do rvm pkg install zlib, and then reinstall the ruby with --with-zlib-dir=/home/username/.rvm/usr, but this didn't work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I ended up installing zlib from apt-get and then reinstalling ruby to not use the rvm directory for zlib.

Here's how do:

$ sudo apt-get install zlib1g-dev
$ rvm reinstall 1.9.3

[Edit] As commenter @chrisfinne mentions, on CentOS/RedHat based systems:

$ sudo yum install zlib-devel
$ rvm reinstall 1.9.3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...