Skip to content

Commit

Permalink
avoid re-resolve (and unlocking) during pre-sync install check (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccutrer authored Oct 5, 2023
1 parent df77890 commit 2106daf
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/bundler/multilock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2106daf

Please sign in to comment.