views:

6855

answers:

13

Hey all, hope you guys can help; I've followed about every tutorial on the net with no luck.

I've just moved over to Ubuntu 8.10 as my dev box; it's my first serious foray into Linux as a daily-use OS, and I'm having a hard time getting Rails going. I have followed a number of tutorials which all seem to work fine, but when I try and use gem install or gem update on anything, I get an error that looks like this:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:5
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:167:in `load_and_instantiate'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:88:in `[]'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:144:in `find_command'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:131:in `process_args'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:102:in `run'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run'
from /usr/local/bin/gem:21

I have (as recommended in the tutorials) installed zlib, zlib1g, and zlib1g-dev. I've even found a few tutorials on this particular problem (all for flavors other than mine, however) but they didn't help.

I'm on Ubuntu 8.10, ruby version 1.8.8dev gem version 1.3.2

I've tried reinstalling ruby and gems each and separately, to no avail.

Thanks Paul

+2  A: 

The problem is that Ruby on Ubuntu isn't built against zlib; you'll want to do a source build to install Ruby. You can do this with apt-get source -b ruby

Don Werve
ok,again, linux noob. No idea what you just said. lol. I mean, I understand the command; but what do I do after that?
Paul
Paul
A: 

You could try to download the ruby enterprise deb package on the phusion site. And install passenger through the package. Follow the instructions here. Or you could try the bash script found here.

Maran
A: 

When running Rails I would not recommend using Ruby 1.8.8dev. Stick with 1.8.6, preferably the Ruby Enterprise Edition. See this post on RailsLab what other people are using.

If you insist on going hi-tech, install Ruby 1.9.1.

But in both cases build it yourself or use Marans suggestion.

harm
A: 

I appreciate your input guys, and I've done my best to follow your advice, but so far no joy; I'm still getting the same error regardless of what method I try. Even the bash script for Ruby Enterprise winds up w/ the same errors as soon as it gets to the first gem command.

Maybe something didn't roll back correctly? Is there something special I need to do to clean up my previous attempts?

Paul
This (and the other "answers") really should be a comment, or edited into the original question...
sth
A: 

Did you try apt-get install libzlib-ruby?

Also install rubygems from rubyforge. I don't like the rubygems package in Ubuntu.

nkassis
+3  A: 

yes, and that didn't do the job either. Got this from another source, this finally did it for me where the other stuff failed.

wget http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz tar xvzf ruby-zlib-0.6.0.tar.gz cd ruby-zlib-0.6.0 ruby extconf.rb && make && make install

Reinstall ruby gems from source

Thanks anyway, guys.

Paul
I had a problem running extconf.rb. Solved it (probably) by installing zlib-devel.
gregers
same here. Tried everything else, and finally blue.sky.or.jp saved me. Thanks.
abhishek
A: 

Hi there,

I had the same problem and tried the solution given here>

wget http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz tar xvzf ruby-zlib-0.6.0.tar.gz cd ruby-zlib-0.6.0 ruby extconf.rb && make && make install

But I have a problem with ruby extconf.rb, as it said:

ruby extconf.rb checking for deflateReset() in -lfalse... no checking for deflateReset() in -llibz... no checking for deflateReset() in-lzlib... no * extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Anyone can help?

Thx

I had the same problem. Suddenly works now. Think installing zlib-devel was the solution.
gregers
A: 

I have this problem.

1) I can confirm that zlib doesn't work against the ruby I compiled. I can test this by running this ruby program:

require 'zlib'

... and get and error message saying zlib cannot be found.

2) I believe this is because the zlib library isn't installed properly on my ubuntu 9 (desktop) install.

I have tried to confirm this by compiling and running a "helloworld.c"-style program, trying to link it against zlib.

I tried these things:

gcc -lzlib helloworld.c

and

gcc -lzlibc helloworld.c

and both gave errors saying that either zlib or zlibc respectively couldn't be found.

I believe this means the libraries can't be found because when I try to link the same program against the math library I get no error message and the program compiles and runs successfully:

gcc -lm helloworld.c

3) Just installing the ubuntu zlibc package doesn't fix it.

I installed the zlibc ubuntu package (with "aptitude install zlibc")

Running steps 1 and 2 above gives the same results after having installed the zlibc package.

Conclusions

i) zlib doesn't work in the compiled ruby because the underlying C library isn't installed properly (i.e. this is a linux C problem causing a ruby problem)

ii) either the package zlibc is the wrong library (wrong version, wrong contents,... or some other value of wrong) OR there's another step I need to take after installing it (?)

Any ideas?

cartoonfox
I was told by Jamie van Dyke (rails core guy) that I should install ruby from source on linux as the debian/ubuntu ruby packages are over-engineered and cause more trouble than they're worth - so I'm really looking for a fix for this zlib problem rather than a pre-cooked ruby for linux.
cartoonfox
You may want to ask a new question, and reference this one as something you tried but which did not work. Not too many people browsing answers to old questions looking for new questions to answer, if you get my drift...
Shog9
Since you have asked this as a separate question you could delete this post here, since it is not really an answer to the original question...
sth
+4  A: 

I have the same problem in CentOS and fix it by executing the following command:

  • First, I ensure that zlib and zlib-devel exist (like many suggested above) yum install zlib zlib-devel

  • Second, I recompiled and installed the sources of zlib that comes with ruby
    cd /home/myname/installers/ruby-1.8.7-p174/ext/zlib/ ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib make
    make
    install

That commands seem to fix the problem, then I execute gem update --system and the error with zlib vanished. Then I install rails with gem install rails. Note to mention I had installed gem before, and after recompile and install zlib, I don't recompile neither install gem (actually I don't knew how uninstall it because I don't found a script to do that)

That works for me...hope to you to.

Regards.

Daniel
This fixed my problem! Please feel my appreciation.
Adrian
A: 

Just goto Ruby Source Package , Unzip it.

Goto /your-ruby-dir/ext/zlib

ruby extconf.rb
make
make install

If the packages are missing it will tell you, mainly libzlib related packages

Regards

Saurabh

Saurabh
+34  A: 

If you come across this question trying to install Ruby using Ruby Version Manager (RVM) on Ubuntu 10.04 then there are instructions on installing zlib on the rvm web site http://rvm.beginrescueend.com/packages/zlib/

The steps are:

rvm package install zlib
rvm remove 1.9.1
rvm install 1.9.1
JosephL
thanks, but i was not using rvm
Paul
I was, and that worked. Thank you.
Jamie van Dyke
Great stuff, thanks. I didn't know about the rvm package command... solved my version of this problem perfectly.
jkrall
great, same approach worked for me with a minor variation for 1.9.2: vm package install zlib ; rvm remove 1.9.2-p0 ; rvm install 1.9.2-p0 --with-zlib-dir=$rvm_path/usr
tardate
wonderful, i was wondering why rvm wasn't working on debian even with zlib installed via apt
Martin DeMello
A: 

try

aptitude install zlib1g-dev

Then go about your business.

Dan
A: 

I am using Ubuntu 10.04 (Lucid), i wanted to install ruby 1.9.2 because 1.9.1 is not recommended with Rails. So I downloaded the source for 1.9.2 and unzipped/unarchived it. my source distro is ruby-1.9.2-p0. After I unpacked it, I built zlib as follows:

cd ruby-1.9.2-p0/ext/zlib
ruby extconf.rb
make
sudo make install
sudo gem install rails

that fixed the problem. This is similar to what other people posted above, but not exactly, so I figured I may as well post exactly what I did to get it going.

AdrianVeidt