如何访问“zip” Ruby 中的 gem(或“rubyzip”)?

发布于 2024-11-08 02:13:12 字数 1320 浏览 6 评论 0原文

我一定错过了一些完全明显的东西,但我似乎无法让 'zip' gem 工作。我已经用 ruby​​gems 安装了它,就像我对许多其他 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

懒的傷心 2024-11-15 02:13:12

试试这个。

gem install rubyzip2

然后

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

Try this.

gem install rubyzip2

then

irb> require 'rubygems'
#=>  true
irb> require 'zip/zip'
#=>  true
# you can also require 'zip/zipfilesystem'
只是在用心讲痛 2024-11-15 02:13:12

对于 ruby​​zip 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文