如何访问“zip” Ruby 中的 gem(或“rubyzip”)?
我一定错过了一些完全明显的东西,但我似乎无法让 'zip' gem 工作。我已经用 rubygems 安装了它,就像我对许多其他 gem 所做的那样。 Rubygem 说它在那里,但当我尝试要求它时,Ruby 说它不在那里。我在 Windows 和 Linux 上都遇到了同样的问题。这是一个 Linux 会话(为简洁起见,删除了额外的输出):
~$ 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
和一个 Windows 会话:
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
我想也许 'zip' 需要一些潜在的依赖项,但我在文档中没有找到任何相关内容。
我对 'rubyzip' 也同样缺乏成功,看来也许 'zip' 和 ' rubyzip' 是分叉吗?
有什么想法吗?或者如果有更好的存档工具,我很想听听。 zip 归档 gem 的选择令人困惑。 gem < a href="http://rubygems.org/gems/zippy" rel="nofollow">'Zippy' 看起来不错,但它需要 'zip' 所以我仍然卡住了。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个。
然后
Try this.
then
对于 rubyzip 1.1.0,正确的要求是
require 'zip'
根据 http://rubydoc 上的文档.info/gems/rubyzip/1.1.0
With rubyzip 1.1.0 the correct require is
require 'zip'
As per the docs at http://rubydoc.info/gems/rubyzip/1.1.0