tags:

views:

4687

answers:

10

I'm trying to install some Ruby Gems so I can use Ruby to notify me when I get twitter messages. However, after doing a "gem update --system", I now get a zlib error every time I try and do a gem install of anything. below is the console output I get when trying to install ruby gems. (along with the output from "gem environment").

C:\data\ruby>gem install twitter
ERROR:  While executing gem ... (Zlib::BufError)
    buffer error

C:\data\ruby>gem update --system
Updating RubyGems
ERROR:  While executing gem ... (Zlib::BufError)
    buffer error

C:\data\ruby>gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.2.0
  - RUBY VERSION: 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
  - INSTALLATION DIRECTORY: c:/ruby/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: c:/ruby/bin/ruby.exe
  - EXECUTABLE DIRECTORY: c:/ruby/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mswin32-60
  - GEM PATHS:
     - c:/ruby/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
A: 

@seanboy

what OS are you running? Vista and gems are known for not playing nice...

mmattax
+1  A: 

A reinstall of Ruby sorted this issue out. It's not what I wanted; I wanted to know why I was getting the issue, but it's all sorted out.

seanyboy
In my case, I think the problem was that I was switching back and forth between rails 2.1.0 and 2.1.2 and I think the dependency installs resulted in things ending up out of whack
srboisvert
Freeze rails into your apps, that way you dont need a seperate gem for it and won't get conflicts.
railsninja
+1  A: 

I just started getting this tonight as well. Googling turned up a bunch of suggestions that didn't deliver results

gem update --system

and some paste in code from jamis that is supposed to replace a function in package.rb but the original it is supposed to replace is nowhere to be found.

Reinstalling rubygems didn't help. I'm reinstalling ruby right now.........and it is fixed. Pain though.

srboisvert
+1  A: 

It most often shows up when your download failed -- i.e. you have a corrupt gem, due to network timeout, faulty manual download, or whatever. Just try again, or download gems manually and point gem at the files.

Asaf Bartov
A: 

I had the same problem with Ruby 1.8.6 on Vista. I tried "gem update --system" as suggested above, and it worked for me. I could update Rails without the "buffer error."

A: 

Try updating ZLib before you do anything else. I had a similar problem on OS X and updating Compress::Zlib (a Perl interface to ZLib) cured it - so I think an old version of ZLib (is now 1.2.3) may be where your problem lies...

Dave Everitt
+4  A: 

Found it! I had the same problem on windows (it appeared suddenly without me doing an update, but whatever):

It has something to do with multiple conflicting zlib versions (I think).

In ruby/lib/ruby/1.8/i386-msvcrt, make sure that there exists a zlib.so file. In my case, it was already there. If not, you may try to install ruby-zlib.

Then go to ruby/lib/ruby/site_ruby/1.8./i386-msvcrt and delete the zlib.so file there.

In ruby/bin, there should be a zlib1.dll. For some reason my Ruby version did not use this dll. I downloaded the most recent version (1.2.3) and installed it there. I had to rename it to zlib.dll for it to be used.

And tada! Rubygems worked again.

Hope this helps.

Wout Neirynck
For me, all I had to do was rename `ruby/bin/zlib1.dll` to `zlib.dll`. It fixed everything.
Andrew
A: 

install pure ruby zlib if all else fails

rogerdpack
A: 

I also have a "zlib error" message, but it appears as I'm playing an old school RPG called "Laxius Power" on Windows XP. How can I fix it?

Lax
A: 

if gem update --system not works and rename ruby/bin/zlib1.dll to zlib.dll not helps try:

Open file RUBY_DIR\lib\ruby\site_ruby\1.8\rubygems.rb

And replace existed def self.gunzip(data) by this:

  def self.gunzip(data)
    require 'stringio'
    require 'zlib'
    data = StringIO.new data

    # Zlib::GzipReader.new(data).read
    data.read(10) # skip the gzip header
    zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
    is = StringIO.new(zis.inflate(data.read))
  end
azproduction