在 Rails 3 的“捆绑安装”中本地宝石(冻结宝石),不断收到“源不包含任何版本......”?
我正在使用位于 vendor/gems/some-api-0.1.0
中的 gem,从另一个项目复制过来,并添加到 Gemfile
中:
gem 'some-api', :path => '~/development/myproj/vendor/gems/some-api-0.1.0'
但是如果我这样做接下来,它将失败并显示消息:
$ bundle install
Fetching source index for http://rubygems.org/
Could not find gem 'some-api (>= 0)' in source at ~/development/myproj/vendor/gems/some-api-0.1.0.
Source does not contain any versions of 'some-api (>= 0)'
在网上搜索似乎建议需要 gemspec?所以我需要在某个地方写一个 .gemspec
,这是真的吗?有人可以阐明在这种情况下是如何完成的吗?
I am using a gem which is in vendor/gems/some-api-0.1.0
, copied over from another project, and added to Gemfile
:
gem 'some-api', :path => '~/development/myproj/vendor/gems/some-api-0.1.0'
but if I do the following, it will fail with the message:
$ bundle install
Fetching source index for http://rubygems.org/
Could not find gem 'some-api (>= 0)' in source at ~/development/myproj/vendor/gems/some-api-0.1.0.
Source does not contain any versions of 'some-api (>= 0)'
Searching on the net seem to suggest needing a gemspec? So I need to write up a .gemspec
some where, is that true? Can someone shred light of how it is done in this situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
stackoverflow 上还有许多其他类似的帖子,但以防万一有人偶然发现这篇文章:
出于某种原因,当您尝试使用本地源的 gem 时,您需要准确指定您正在使用的 gem 的版本,例如
There are many other similar posts on stackoverflow, but just in case someone stumble across this post:
For some reason, when you are trying to use a gem from local source, you need to specify exactly which version of the gem you are using, e.g.
仅仅声称 :path 中有一个 gem 并不意味着那里实际上有一个 gem。 Gem 具有 gemspec 文件,描述 gem 的名称、属于该 gem 的文件以及各种其他信息。
如果
some-api-0.1.0
应在 :path 目录中包含名为some-api.gemspec
的文件,并且它应包含有关捆绑程序可以使用的 gem 的信息要求 gem 离开 :path。Just claiming there is a gem in the :path doesn't mean there actually is a gem there. Gems have gemspec files describing the name of the gem, what files belong to the gem, and various other information.
If
some-api-0.1.0
should contain a file namedsome-api.gemspec
in the :path directory, and it should contain information about the gem that bundler could use to require the gem out of the :path.