From 2106dafe188a9fb6bccb69a81117caea77921d25 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Thu, 5 Oct 2023 12:50:48 -0600 Subject: [PATCH] avoid re-resolve (and unlocking) during pre-sync install check (#5) --- lib/bundler/multilock.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/bundler/multilock.rb b/lib/bundler/multilock.rb index d2c049b..0ca4956 100644 --- a/lib/bundler/multilock.rb +++ b/lib/bundler/multilock.rb @@ -406,23 +406,23 @@ def write_lockfile(lockfile_definition, lockfile, install:, dependency_changes: definition = builder.to_definition(lockfile, { bundler: unlocking_bundler }) definition.instance_variable_set(:@dependency_changes, dependency_changes) if dependency_changes - orig_definition = definition.dup # we might need it twice current_lockfile = lockfile_definition[:lockfile] - if current_lockfile.exist? - definition.instance_variable_set(:@lockfile_contents, current_lockfile.read) - if install - current_definition = builder.to_definition(current_lockfile, { bundler: unlocking_bundler }) - begin - current_definition.resolve_with_cache! - if current_definition.missing_specs.any? - Bundler.with_default_lockfile(current_lockfile) do - Installer.install(gemfile.dirname, current_definition, {}) - end + definition.instance_variable_set(:@lockfile_contents, current_lockfile.read) if current_lockfile.exist? + + orig_definition = definition.dup # we might need it twice + + if current_lockfile.exist? && install + Bundler.settings.temporary(frozen: true) do + current_definition = builder.to_definition(current_lockfile, {}) + current_definition.resolve_with_cache! + if current_definition.missing_specs.any? + Bundler.with_default_lockfile(current_lockfile) do + Installer.install(gemfile.dirname, current_definition, {}) end - rescue RubyVersionMismatch, GemNotFound, SolveFailure - # ignore end + rescue RubyVersionMismatch, GemNotFound, SolveFailure + # ignore end end