How to access 'zip' gem (or 'rubyzip') in Ruby?

I must be missing something totally obvious but I can't seem to get the 'zip' gem to work. I've installed it with rubygems just like I've done with many other gems. Rubygem says it's there but yet when I try to require it, Ruby says it's not there. I'm experiencing the same problem on both Windows and Linux. Here's a Linux session (extra output removed for brevity):

~$ ruby -v ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux] ~$ gem list z ~$ sudo gem install zip Successfully installed zip-2.0.2 ~$ irb irb(main):001:0> require 'zip/zip' LoadError: no such file to load -- zip/zip from (irb):1:in `require' from (irb):1 from :0 

And a Windows session:

C:\> ruby -v ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32] C:\> gem list z C:\> gem install zip Successfully installed zip-2.0.2 C:\> irb irb(main):001:0> require 'zip/zip' LoadError: no such file to load -- zip/zip from (irb):1:in `require' from (irb):1 

I'm thinking perhaps there's some underlying dependency that 'zip' needs but I haven't found anything about that in the docs.

I've also had the same lack of success with 'rubyzip' It seems that perhaps 'zip' and 'rubyzip' are forks?

Any ideas? Or if there's a better gem out there for archiving, I'd love to hear about it. The choice of zip archiving gems is confusing. The gem 'Zippy' looks good but it requires 'zip' so I'm still stuck.

2 Answers

Try this.

gem install rubyzip2 

then

irb> require 'rubygems' #=> true irb> require 'zip/zip' #=> true # you can also require 'zip/zipfilesystem' 
5

With rubyzip 1.1.0 the correct require is

require 'zip'

As per the docs at

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like