[rubygems/rubygems] Fix parallel installation issue

If using a gem with precompiled versions having different dependencies
than the generic version from a path source, and with a lockfile
including a precompiled version, we would materialize the
generic version, but end up using dependencies for the precompiled
version. That will result in the parallel installer missing the
specifications for the extra dependencies of the generic version,
causing a crash.

If we are materializing for installation, make sure we use the
materialized specification when traversing dependencies.

https://github.com/rubygems/rubygems/commit/5f75d75de7
This commit is contained in:
David Rodríguez 2025-09-15 20:40:43 +02:00 committed by Hiroshi SHIBATA
parent 8edb029ed9
commit a65c7c8428
2 changed files with 50 additions and 1 deletions

View File

@ -29,7 +29,7 @@ module Bundler
end
def dependencies
specs.first.runtime_dependencies.map {|d| [d, platform] }
(materialized_spec || specs.first).runtime_dependencies.map {|d| [d, platform] }
end
def materialized_spec

View File

@ -831,6 +831,55 @@ RSpec.describe "bundle install with explicit source paths" do
end
end
context "when platform specific version locked, and having less dependencies that the generic version that's actually installed" do
before do
build_repo4 do
build_gem "racc", "1.8.1"
build_gem "mini_portile2", "2.8.2"
end
build_lib "nokogiri", "1.18.9", path: lib_path("nokogiri") do |s|
s.add_dependency "mini_portile2", "~> 2.8.2"
s.add_dependency "racc", "~> 1.4"
end
gemfile <<~G
source "https://gem.repo4"
gem "nokogiri", path: "#{lib_path("nokogiri")}"
G
lockfile <<~L
PATH
remote: #{lib_path("nokogiri")}
specs:
nokogiri (1.18.9)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.9-arm64-darwin)
racc (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
racc (1.8.1)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
nokogiri!
BUNDLED WITH
#{Bundler::VERSION}
L
end
it "works" do
bundle "install"
end
end
describe "switching sources" do
it "doesn't switch pinned git sources to rubygems when pinning the parent gem to a path source" do
build_gem "foo", "1.0", to_system: true do |s|