Skip to content

Commit

Permalink
fix syncing transitive dependencies when the root dependency is in co…
Browse files Browse the repository at this point in the history
…nflict (#44)
  • Loading branch information
ccutrer authored May 18, 2024
1 parent 5ba3464 commit ef06119
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
15 changes: 10 additions & 5 deletions lib/bundler/multilock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ def after_install_all(install: true)

# already up to date?
up_to_date = false
conflicts = Set.new
Bundler.settings.temporary(frozen: true) do
Bundler.ui.silence do
up_to_date = checker.base_check(lockfile_definition, check_missing_deps: true) &&
checker.deep_check(lockfile_definition)
checker.deep_check(lockfile_definition, conflicts: conflicts)
end
end
if up_to_date
Expand Down Expand Up @@ -247,10 +248,14 @@ def after_install_all(install: true)
next :self if parent_spec.nil?
next spec_precedences[spec.name] if spec_precedences.key?(spec.name)

precedence = :self if cache.conflicting_requirements?(lockfile_name,
parent_lockfile_name,
spec,
parent_spec)
precedence = if !(cache.reverse_dependencies(lockfile_name)[spec.name] & conflicts).empty?
:parent
elsif cache.conflicting_requirements?(lockfile_name,
parent_lockfile_name,
spec,
parent_spec)
:self
end

spec_precedences[spec.name] = precedence || :parent
end
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/multilock/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def base_check(lockfile_definition, check_missing_deps: false)

# this checks for mismatches between the parent lockfile and the given lockfile,
# and for pinned dependencies in lockfiles requiring them
def deep_check(lockfile_definition)
def deep_check(lockfile_definition, conflicts: nil)
lockfile_name = lockfile_definition[:lockfile]
@cache.deep_check(lockfile_name) do
success = true
Expand Down Expand Up @@ -156,6 +156,7 @@ def deep_check(lockfile_definition)
"does not match the parent lockfile's version " \
"(@#{parent_spec.version}#{parent_spec.git_version}); " \
"this may be due to a conflicting requirement, which would require manual resolution.")
conflicts&.add(spec.name)
success = false
end

Expand Down
4 changes: 0 additions & 4 deletions spec/bundler/multilock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,6 @@
end

it "keeps transitive dependencies in sync, even when the intermediate deps are conflicting" do
pending "this spec was broken when improving _not_ unlocking all gems when syncing to alternate lockfiles. " \
"it was determined that until such a problem arises again, it's not worth the effort to fix at " \
"the moment"

orig_gemfile = <<~RUBY
gem "ddtrace", "~> 1.13"
Expand Down

0 comments on commit ef06119

Please sign in to comment.