Skip to content

Commit d34bcd6

Browse files
committed
fix syncing transitive dependencies when the root dependency is in conflict
just take the output of the check command, and force any downstreams of those conflicts to update to the parent
1 parent 5ba3464 commit d34bcd6

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

lib/bundler/multilock.rb

+10-5
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ def after_install_all(install: true)
175175

176176
# already up to date?
177177
up_to_date = false
178+
conflicts = Set.new
178179
Bundler.settings.temporary(frozen: true) do
179180
Bundler.ui.silence do
180181
up_to_date = checker.base_check(lockfile_definition, check_missing_deps: true) &&
181-
checker.deep_check(lockfile_definition)
182+
checker.deep_check(lockfile_definition, conflicts: conflicts)
182183
end
183184
end
184185
if up_to_date
@@ -247,10 +248,14 @@ def after_install_all(install: true)
247248
next :self if parent_spec.nil?
248249
next spec_precedences[spec.name] if spec_precedences.key?(spec.name)
249250

250-
precedence = :self if cache.conflicting_requirements?(lockfile_name,
251-
parent_lockfile_name,
252-
spec,
253-
parent_spec)
251+
precedence = if !(cache.reverse_dependencies(lockfile_name)[spec.name] & conflicts).empty?
252+
:parent
253+
elsif cache.conflicting_requirements?(lockfile_name,
254+
parent_lockfile_name,
255+
spec,
256+
parent_spec)
257+
:self
258+
end
254259

255260
spec_precedences[spec.name] = precedence || :parent
256261
end

lib/bundler/multilock/check.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def base_check(lockfile_definition, check_missing_deps: false)
8888

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

spec/bundler/multilock_spec.rb

-4
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,6 @@
815815
end
816816

817817
it "keeps transitive dependencies in sync, even when the intermediate deps are conflicting" do
818-
pending "this spec was broken when improving _not_ unlocking all gems when syncing to alternate lockfiles. " \
819-
"it was determined that until such a problem arises again, it's not worth the effort to fix at " \
820-
"the moment"
821-
822818
orig_gemfile = <<~RUBY
823819
gem "ddtrace", "~> 1.13"
824820

0 commit comments

Comments
 (0)