Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix syncing transitive dependencies when the root dependency is in conflict #44

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading