From 4f5805fd61974bf654164e205d24b6091d6ba89b Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Tue, 10 Feb 2026 01:11:58 +0100 Subject: [PATCH] [ruby/rubygems] Run git operations in parallel (take 2): - In #9100, I opened a patch to run git operations in parallel in order to download git gems more quickly. The parallelization doesn't works when resolving is not needed due to a premature call to `source.specs` hit by this codepath. You can reproduce the problem and see that the gems aren't downloaded in parallel if you have an existing Gemfile and Gemfile.lock. (In my first patch, I forgot to try when a Gemfile.lock already existed). I'd like to introduce a new call to `prelad_git_sources`, when bundler hits the "missing specs" branch. I unforunately couldn't find a single place where we could preload git sources due to the `source.specs` that is called at different path. https://github.com/ruby/rubygems/commit/f25b40f21f --- lib/bundler/definition.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 4c0c33753526b5..efc749e9b32626 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -249,6 +249,7 @@ def removed_specs end def missing_specs + preload_git_sources resolve.missing_specs_for(requested_dependencies) end @@ -1125,9 +1126,17 @@ def preload_git_source_worker end def preload_git_sources - needed_git_sources.each {|source| preload_git_source_worker.enq(source) } - ensure - preload_git_source_worker.stop + if Gem.ruby_version < Gem::Version.new("3.3") + # Ruby 3.2 has a bug that incorrectly triggers a circular dependency warning. This version will continue to + # fetch git repositories one by one. + return + end + + begin + needed_git_sources.each {|source| preload_git_source_worker.enq(source) } + ensure + preload_git_source_worker.stop + end end # Git sources needed for the requested groups (excludes sources only used by --without groups) @@ -1144,11 +1153,7 @@ def excluded_git_sources end def find_source_requirements - if Gem.ruby_version >= Gem::Version.new("3.3") - # Ruby 3.2 has a bug that incorrectly triggers a circular dependency warning. This version will continue to - # fetch git repositories one by one. - preload_git_sources - end + preload_git_sources # Record the specs available in each gem's source, so that those # specs will be available later when the resolver knows where to