From a65c7c8428fb2c50672e8e2f1d27e1416870cb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <2887858+deivid-rodriguez@users.noreply.github.com> Date: Mon, 15 Sep 2025 20:40:43 +0200 Subject: [PATCH] [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 --- lib/bundler/materialization.rb | 2 +- spec/bundler/install/gemfile/path_spec.rb | 49 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/bundler/materialization.rb b/lib/bundler/materialization.rb index 43124f25fb..82e48464a7 100644 --- a/lib/bundler/materialization.rb +++ b/lib/bundler/materialization.rb @@ -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 diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb index 55bf11928d..ea59f11bbe 100644 --- a/spec/bundler/install/gemfile/path_spec.rb +++ b/spec/bundler/install/gemfile/path_spec.rb @@ -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|