开发者

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 inst开发者_如何学JAVAalled 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.


Try this.

gem install rubyzip2

then

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


With rubyzip 1.1.0 the correct require is

require 'zip'

As per the docs at http://rubydoc.info/gems/rubyzip/1.1.0

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜