我正在编写一个 Ruby gem/Rails 引擎,blacklight_allmaps,并使用 GitHub Actions 进行 CI。昨天,我的 Ruby v3.2 测试构建顺利通过,但我的 Ruby v3.3 测试开始失败并出现一个奇怪的错误:
Could not find gems matching 'blacklight_allmaps (= 0.2.0)' valid for all
resolution platforms () in source at
`/home/runner/work/blacklight-allmaps/blacklight-allmaps`.
The source contains the following gems matching 'blacklight_allmaps (= 0.2.0)':
* blacklight_allmaps-0.2.0
Done generating test app
/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/resolver.rb:336:in `raise_not_found!': Could not find gems matching 'blacklight_allmaps (= 0.2.0)' valid for all resolution platforms () in source at `/home/runner/work/blacklight-allmaps/blacklight-allmaps`. (Bundler::GemNotFound)
The source contains the following gems matching 'blacklight_allmaps (= 0.2.0)':
* blacklight_allmaps-0.2.0
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:613:in `block in materialize'
from <internal:kernel>:187:in `loop'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:600:in `materialize'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:203:in `specs'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:270:in `specs_for'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/runtime.rb:18:in `setup'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler.rb:162:in `setup'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/setup.rb:26:in `block in <top (required)>'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/ui/shell.rb:159:in `with_level'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/ui/shell.rb:111:in `silence'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/setup.rb:26:in `<top (required)>'
from <internal:/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
from <internal:/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/rubygems.rb:1382:in `<top (required)>'
from <internal:gem_prelude>:2:in `require'
from <internal:gem_prelude>:2:in `<internal:gem_prelude>'
/opt/hostedtoolcache/Ruby/3.3.1/x64/bin/ruby -I/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.0/lib:/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/gems/3.3.0/gems/rspec-support-3.13.1/lib /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/resolver.rb:336:in `raise_not_found!': Could not find gems matching 'blacklight_allmaps (= 0.2.0)' valid for all resolution platforms () in source at `/home/runner/work/blacklight-allmaps/blacklight-allmaps`. (Bundler::GemNotFound)
The source contains the following gems matching 'blacklight_allmaps (= 0.2.0)':
* blacklight_allmaps-0.2.0
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:613:in `block in materialize'
from <internal:kernel>:187:in `loop'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:600:in `materialize'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:203:in `specs'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/definition.rb:270:in `specs_for'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/runtime.rb:18:in `setup'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler.rb:162:in `setup'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/setup.rb:26:in `block in <top (required)>'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/ui/shell.rb:159:in `with_level'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/ui/shell.rb:111:in `silence'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/bundler/setup.rb:26:in `<top (required)>'
from <internal:/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
from <internal:/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
from /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/rubygems.rb:1382:in `<top (required)>'
from <internal:gem_prelude>:2:in `require'
from <internal:gem_prelude>:2:in `<internal:gem_prelude>'
/opt/hostedtoolcache/Ruby/3.3.1/x64/bin/ruby -I/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.0/lib:/opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/gems/3.3.0/gems/rspec-support-3.13.1/lib /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed
重新运行两周前通过 CI 的测试版本现在也失败并出现同样的错误:https://github.com/bplmaps/blacklight-allmaps/actions/runs/8668487468
这似乎可能与最近的 Ruby v3.3.1 和 Bundler v2.5.9 版本有关,但即使我尝试将 Ruby 固定到 v3.3.0,将 Bundler 固定到 v2.5.5,我仍然看到相同的错误。
有人有什么建议吗?我缺乏如何排除故障的想法。
尝试回滚到 Ruby v3.3.0 和 Blunder v2.5.5,但此错误仍然存在。
强制将一个平台纳入我的 CI 工作流程的捆绑包中解决了这个问题。
在我的 GitHub Actions CI 工作流程文件中,我添加了一个“锁定平台版本”条目:
...
- name: Lock platform version
run: bundle lock --add-platform ruby
- name: Install dependencies
run: bundle install
...
完成此更改后,Ruby v3.3.1 就有了一个可以使用的捆绑平台,之后它解析了我正在编写的本地 blacklight_allmaps gem。
我不知道为什么这是必要的......这对我来说在 Ruby 链上太远了,但它允许我的构建完成并且测试能够正常运行。
我会赢得胜利。