I struggled with Zlib error for hours now and internet world seems to be convinced with the
gem update --system
solution.
Although, the aforementioned is indeed a solution, in my case I got the Zlib error even for
gem update --system
command.
Turns out that you need to update the rubygems-update by:
gem install rubygems-update
If the above command doesn't work as it is, try fetching the rubygems-update to the local repository first by:
gem fetch rubygems-update -v 1.4.0
In my situation, even gem fetch rubygems-update -v 1.4.0
did not work, because it requires the latest build of ruby installed (1.8.7) and I had 1.8.6p26. The trick is to manually download rubygems-update gem, then go to the download directory and install the gem.
After you're done, do:
gem update --system
and proceed with whatever gems you need to install.
Hope this works for a clueless googler like me :)
Oh! While we're on it... I also had an "Application failed to initialize properly" windows error with cl.exe (Cl.exe is some Microsoft Visual Studio executable by the way.) while trying to do:
gem install win32-api -v
Apparently, this requires native C library compilation and I am thinking, because of visual studio installation, my native C library pointed to some dll accessed by cl.exe to which ruby didn't have access and so, the windows error.... As a naive windows user, I uninstalled the Visual studio and the error was gone :)
This reminds me of this girl colleague I went out for lunch with. A guy called her and asked her what to do if CPU usage is 70% even if no application is running. She told him to restart the PC and if that doesn't fix the problem... format it.
I laughed at it and she hates me now (I guess) :P
Cheers!
Vital update:
As it turns out, your life can be made much more easier if you are on a non-windows computer and you use ruby version manager instead of manual ruby installation. rvm will take care of all the version compatibilities etc that you need. RVM also needs a utility that allows users to download stuff on command line. It's called as cUrl and comes pre-installed with a Mac (and I am guessing with linux distributions too).
Another update:
This morning, a colleague came upto me with a similar problem. Manual download of rubygems 1.4.0 worked as expected, but apparently gem update --system ended up installing newer version of watir and few other gems. If there are multiple versions of same gems installed, a require statement in your ruby script might get confused with the paths and might throw errors like require_all not found or package custom_require not found. You should uninstall the unwanted ruby gem versions in such a case!