diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb index bb26bdc91178..9cce3f8b81ca 100644 --- 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 diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index 4a7b6038837e..077ced68c1d0 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -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 diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb index 185df1b1c733..29fca3962fd1 100644 --- a/spec/resolver/basic_spec.rb +++ b/spec/resolver/basic_spec.rb @@ -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" diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb index 9fff107e02d3..57dd0595b927 100644 --- a/test/rubygems/test_gem_resolver.rb +++ b/test/rubygems/test_gem_resolver.rb @@ -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| diff --git a/tool/automatiek/pub_grub-rubygems.patch b/tool/automatiek/pub_grub-rubygems.patch index 4a45b87564d0..b7eaf67411f9 100644 --- a/tool/automatiek/pub_grub-rubygems.patch +++ b/tool/automatiek/pub_grub-rubygems.patch @@ -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