Skip to content
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
2 changes: 1 addition & 1 deletion lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def negative?
end

def empty?
@empty ||= normalized_constraint.empty?
@empty ||= constraint.empty?
end

def inspect
Expand Down
5 changes: 3 additions & 2 deletions spec/commands/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1918,8 +1918,9 @@

Because rails >= 7.0.4 depends on railties = 7.0.4
and rails < 7.0.4 depends on railties = 7.0.3.1,
railties = 7.0.3.1 OR = 7.0.4 is required.
So, because railties = 7.0.3.1 OR = 7.0.4 could not be found in rubygems repository https://gem.repo4/ or installed locally,
every version of rails requires railties = 7.0.3.1 OR = 7.0.4.
So, because railties = 7.0.3.1 OR = 7.0.4 could not be found in rubygems repository https://gem.repo4/ or installed locally
and Gemfile depends on rails >= 7.0.3.1,
version solving has failed.
ERR
end
Expand Down
16 changes: 16 additions & 0 deletions spec/resolver/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@
should_resolve_as %w[activemodel-3.2.11 builder-3.0.4 grape-0.2.6 my_app-1.0.0]
end

it "backtracks when all versions of a dependency conflict" do
@index = build_index do
gem "aa", "1.0.0"
gem "aa", "2.0.0" do
dep "ff", ">= 0"
dep "ll", ">= 0"
end
gem("ff", "1.0.0") { dep "ll", "< 1" }
gem("ff", "2.0.0") { dep "ll", "= 3" }
gem "ll", "2.0.0"
end
dep "aa"

should_resolve_as %w[aa-1.0.0]
end

it "resolves a complex conflicting index" do
@index = a_complex_conflict_index
dep "my_app"
Expand Down
12 changes: 12 additions & 0 deletions test/rubygems/test_gem_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,18 @@ def test_backtracks_to_clean_sibling_when_higher_version_has_missing_dep
assert_resolves_to [a1], r
end

def test_backtracks_when_all_versions_of_a_dependency_conflict
aa1 = util_spec "aa", "1.0.0"
aa2 = util_spec "aa", "2.0.0", "ff" => nil, "ll" => nil
ff1 = util_spec "ff", "1.0.0", "ll" => "< 1"
ff2 = util_spec "ff", "2.0.0", "ll" => "= 3"
ll = util_spec "ll", "2.0.0"

resolver = Gem::Resolver.new([make_dep("aa")], set(aa1, aa2, ff1, ff2, ll))

assert_resolves_to [aa1], resolver
end

def test_backtracks_over_band_of_bad_high_versions_to_clean_lower
a1 = util_spec "a", "1"
a2 = util_spec "a", "2" do |s|
Expand Down
12 changes: 12 additions & 0 deletions tool/automatiek/pub_grub-rubygems.patch
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,15 @@ diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/strategy.rb b/lib/rubygem
end

def next_term_to_try_from(unsatisfied)
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb
--- a/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb
@@ -95,7 +95,7 @@ def negative?
end

def empty?
- @empty ||= normalized_constraint.empty?
+ @empty ||= constraint.empty?
end

def inspect
Loading