gpt4 book ai didi

ruby - 使用自定义 gem 源的 bundler 出现 "Could not find gem …"错误

转载 作者:数据小太阳 更新时间:2023-10-29 06:54:57 26 4
gpt4 key购买 nike

在我的 Gemfile 中,我需要一个来自自定义源的 gem,其中包含以下行:

gem 'very-secret-gem', source:'https://foo.example.com/'

bundle install 完成正常:

$ bundle install
Fetching source index from https://foo.example.com/
Fetching source index from https://foo.example.com/
Fetching gem metadata from https://rubygems.org/........

Resolving dependencies...

Installing very-secret-gem 1.5.1

Bundle complete! 47 Gemfile dependencies, 116 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

但是运行使用 ruby​​ 的命令失败(此处为空 Rakefile):

$ bundle exec rake -T
Could not find gem 'very-secret-gem (>= 0) ruby' in rubygems repository https://foo.example.com/.
Source does not contain any versions of 'very-secret-gem (>= 0) ruby'
Run `bundle install` to install missing gems.

此时按照错误消息中的建议运行 bundle install 将无济于事。

为什么会这样,如何解决?

如果我在源代码块中指定 gem,它同样会失败:

source 'https://foo.example.com/' do
gem 'very-secret-gem'
end

更有趣的是,如果我在文件的开头指定源,而不绑定(bind)任何 gem,它工作正常:

source 'https://rubygems.org'
source 'https://foo.example.com/'
gem 'very-secret-gem'

...但 bundler 建议不要这样做:

Warning: this Gemfile contains multiple primary sources. Using `source`
more than once without a block is a security risk, and may result in
installing unexpected gems. To resolve this warning, use a block to
indicate which gems should come from the secondary source. To upgrade
this warning to an error, run `bundle config disable_multisource true`.

版本:

$ ruby -v    # => ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
$ gem -v # => 2.4.5
$ bundle -v # => Bundler version 1.8.2

更新

似乎是一个 bundle 程序错误。另一个带有 :pathgem 的存在似乎是触发它的原因。测试应用程序在这里:https://github.com/kch/bundler-source-bug

此处 bundler 的 GH 问题:https://github.com/bundler/bundler/issues/3417

最佳答案

这应该在 Bundler 1.8.3(今天发布)中得到修复。

关于ruby - 使用自定义 gem 源的 bundler 出现 "Could not find gem …"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28557998/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com