diff --git a/lib/bundler/multilock.rb b/lib/bundler/multilock.rb index f38f11d..c3a5ce5 100644 --- a/lib/bundler/multilock.rb +++ b/lib/bundler/multilock.rb @@ -167,7 +167,7 @@ def after_install_all(install: true) up_to_date = false Bundler.settings.temporary(frozen: true) do Bundler.ui.silence do - up_to_date = checker.base_check(lockfile_definition) && + up_to_date = checker.base_check(lockfile_definition, check_missing_deps: true) && checker.check(lockfile_definition) end end diff --git a/lib/bundler/multilock/check.rb b/lib/bundler/multilock/check.rb index 4b7a87b..662f381 100644 --- a/lib/bundler/multilock/check.rb +++ b/lib/bundler/multilock/check.rb @@ -58,7 +58,7 @@ def run(skip_base_checks: false) # this is mostly equivalent to the built in checks in `bundle check`, but even # more conservative, and returns false instead of exiting on failure - def base_check(lockfile_definition, log_missing: false, return_missing: false) + def base_check(lockfile_definition, log_missing: false, return_missing: false, check_missing_deps: false) return return_missing ? [] : false unless lockfile_definition[:lockfile].file? Multilock.prepare_block = lockfile_definition[:prepare] @@ -83,7 +83,10 @@ def base_check(lockfile_definition, log_missing: false, return_missing: false) return not_installed if return_missing - not_installed.empty? && definition.no_resolve_needed? + return false unless not_installed.empty? && definition.no_resolve_needed? + return true unless check_missing_deps + + (definition.locked_gems.dependencies.values - definition.dependencies).empty? ensure Multilock.prepare_block = nil end diff --git a/spec/bundler/multilock_spec.rb b/spec/bundler/multilock_spec.rb index 872b5c0..5013b67 100644 --- a/spec/bundler/multilock_spec.rb +++ b/spec/bundler/multilock_spec.rb @@ -716,6 +716,26 @@ end end + it "removes now-missing explicit dependencies from secondary lockfiles" do + with_gemfile(<<~RUBY) do + gem "inst-jobs", "3.1.13" + gem "activerecord-pg-extensions" + + lockfile("alt") {} + RUBY + invoke_bundler("install") + + write_gemfile(<<~RUBY) + gem "inst-jobs", "3.1.13" + + lockfile("alt") {} + RUBY + + invoke_bundler("install") + expect(File.read("Gemfile.lock")).to eq File.read("Gemfile.alt.lock") + end + end + private def create_local_gem(name, content = "", subdirectory: true)