如何将 Bundler 与离线 .gem 文件一起使用? [英] How to use Bundler with offline .gem file?

查看:15
本文介绍了如何将 Bundler 与离线 .gem 文件一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的应用程序,我需要处理加密的 ZIP 文件.尽管他们的网站看起来很可怕,但似乎 Chilkat 的 commercial Zip gem 可能是最好的方式去实现这个.

For my application, I need to handle encrypted ZIP files. Despite their horrific looking site, it seems that Chilkat's commercial Zip gem is probably the best way to go to implement this.

因为这是一个商业 gem,所以 Bundler 所查看的任何典型 gem 资源中都没有它.我能够在 Mac OS X 下安装 Linux 64 位版本的 gem(虽然我还没有尝试运行它,所以还没有关于它是否真的有效的消息).但是,我首先尝试让 Bundler 识别并从我下载的 .gem 文件中加载 gem.

Because this is a commercial gem, they don't have it in any of the typical gem sources that Bundler looks at. I was able to install the Linux 64-bit version of the gem under Mac OS X (though I haven't tried to run it yet, so no word yet on if that will actually work). However, I'm first trying to get Bundler to recognize and load the gem from the .gem file that I downloaded.

Bundler 有一个 path 属性,我尝试以多种方式使用它,但我没有还没开始工作:

Bundler has a path attribute which I've tried to utilize in several ways, but I haven't gotten it to work yet:

  1. 我尝试使用 path 指向 .gem 文件本身,但 path 需要一个目录.
  2. 我尝试将 .gz 添加到 .gem 文件的末尾并解压缩 - 我得到了一个目录,其中包含 data.tar.gz 和 metadata.gz.指向包含这两个文件的提取目录的路径不起作用.
  3. 我尝试提取 data.tar.gz 和 metadata.gz 并将提取的版本放在我指向路径的目录中.这失败了.
  4. 我注意到 gem 没有 gemspec 文件 - 我创建了一个并将其放在目录中.不走运.

这是我得到的错误:

$ bundle install
Fetching source index for http://rubygems.org/
Fetching source index for http://gems.github.com/
Could not find gem 'chilkat (>= 0, runtime)' in source at /Users/username/appname/vendor/cache/chilkat-9.1.0-x86_64-linux.
Source does not contain any versions of 'chilkat (>= 0, runtime)'

关于如何让 Bundler 看到 gem 确实在这个目录中的任何想法?除了似乎不起作用的路径属性之外的任何其他选项?

Any ideas on how I can get Bundler to see that the gem is indeed in this directory? Any other options other than the path attribute which doesn't seem to be working?

非常感谢!

推荐答案

我使用的是 Rails 3.0.3,是 Rails 3 和 bundler 的新手.

I'm using Rails 3.0.3, new to Rails 3 and bundler.

我遇到了同样的错误:

gem 'mygem', :path => '/path/to/gem'

通过指定版本号解决:

gem 'mygem', '0.0.1', :path => '/path/to/gem'

使用 >=0.0.1 将版本恢复为原始错误.但是,我无法解释这些.

Using >=0.0.1 for the version reverted to the original error. I can't explain any of this, however.

在 Gemfile 手册页中引用 JD 的有用评论:类似于 :git 选项的语义,:path 选项要求相关目录包含 gem 的 .gemspec,或者您指定显式捆绑器应该使用的版本."

Quoting JD's helpful commment, from the Gemfile man page: "Similar to the semantics of the :git option, the :path option requires that the directory in question either contains a .gemspec for the gem, or that you specify an explicit version that bundler should use."

这篇关于如何将 Bundler 与离线 .gem 文件一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆