English 中文(简体)
RVM Ruby 1.9.1 install can t locate zlib but its runtime and dev library are there
原标题:

Trying to get Ruby 1.9.1 up and running with RVM on a fresh install (fedora).

After doing rvm install 1.9.1, the rubygems error logs show that zlib can t be located

no such file to load -- zlib (LoadError)

However both the zlib runtime and development libraries are installed and up-to-date.

I m kinda stumped on this one at the moment.

问题回答

Use rvm to install zlib

https://rvm.io/packages/zlib/

rvm package install zlib
rvm remove 1.9.1
rvm install 1.9.1 -C --with-zlib-dir=$rvm_path/usr

Edit: The rvm package command was renamed to rvm pkg in v1.6.25.

You need to install zlib before compiling/installing Ruby. If you didn t do this, make sure to remove everything related to Ruby 1.9.1 from your ~/.rvm folder (so that it will be build from scratch).

Install zlib using your favorite package manager:

sudo apt-get install zlib1g-dev

You might also want to install the following packages as they are required by tools like OpenSSL,
Nokogiri, IRB or SQLite:

 libssl-dev libreadline6-dev libxml2-dev libsqlite3-dev

Then install Ruby 1.9.1 again (nowadays I would suggest to use a newer version):

rvm install 1.9.1

Watch for "compiling ...". This should take a while. If it doesn t, then Ruby 1.9.1 might still be cached
in your ~/.rvm folder.

I encountered this problem when trying to:

gem install gruff

What actually worked for me (Ubunut 10.10, ruby MRI 1.8.7) is:

  • reading the rvm notes and installing the dependencies for my ruby version

sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf

  1. rvm package install zlib
  2. rvm remove 1.8.7
  3. rvm install 1.8.7

So basically: just follow the rvm manual

In modern version of rvm package argument have been replaced pkg argument.

Now, in order to install zlib package for rvm need:

rvm pkg install zlib

Since you are using Fedora try running:

yum install zlib-devel.i686

And then try installing ruby 1.9.1 using RVM

rvm install 1.9.1

Also, you do know that 1.9.1 is horribly broken which is why no one uses it seriously, right? The importance this has to the question asked is that many people do not realize this and attempt to use it with such APIs as Ruby On Rails. However, as rubyonrails.org/download states, Ruby 1.9.1 is not supported for use with Rails as it is broken.

On the latest Ubuntu (11.10) there is also an issue with readline.

Readline was unable to be required, if you need completion or history install readline then reinstall ruby.

So my entire rvm and latest ruby install process for ubunutu 11.10 was:

# install rvm
sudo apt-get install curl
curl -L get.rvm.io | bash -s stable

# install dependencies
rvm pkg install zlib
rvm pkg install readline

# install additional dependencies -- follow instructions for your distribution/version
rvm requirements

# install ruby
rvm install [ruby-version]

I m posting this for my future reference and in case anyone else bumps into this issue as well.

For me, the solution was very simple: I had forgotten to close/reopen the shell, as rvm setup had instructed me to do. After I did that, the zlib error was gone and I was able to: gem install bundler





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签