[rubygems/rubygems] Let resolver consider unique specs from the beginning

It results in more consistent error messages.

https://github.com/rubygems/rubygems/commit/a4b34361cc
This commit is contained in:
David Rodríguez 2024-07-04 22:09:34 +02:00 коммит произвёл git
Родитель a333e867aa
Коммит 5fdfdc30f1
2 изменённых файлов: 7 добавлений и 23 удалений

Просмотреть файл

@ -79,7 +79,7 @@ module Bundler
def solve_versions(root:, logger:)
solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
result = solver.solve
result.map {|package, version| version.to_specs(package) }.flatten.uniq
result.map {|package, version| version.to_specs(package) }.flatten
rescue PubGrub::SolveFailure => e
incompatibility = e.incompatibility
@ -270,6 +270,7 @@ module Bundler
end
platform_specs.flatten!
platform_specs.uniq!
ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
groups << Resolver::Candidate.new(version, specs: ruby_specs) if ruby_specs.any?

Просмотреть файл

@ -1467,9 +1467,7 @@ RSpec.describe "bundle lock" do
#{Bundler::VERSION}
L
bundle "lock", raise_on_error: false
expect(err).to eq <<~ERR.strip
expected_error = <<~ERR.strip
Could not find compatible versions
Because every version of activemodel depends on activesupport = 6.0.4
@ -1493,28 +1491,13 @@ RSpec.describe "bundle lock" do
version solving has failed.
ERR
bundle "lock", raise_on_error: false
expect(err).to eq(expected_error)
lockfile lockfile.gsub(/PLATFORMS\n #{local_platform}/m, "PLATFORMS\n #{lockfile_platforms("ruby")}")
bundle "lock", raise_on_error: false
expect(err).to eq <<~ERR.strip
Could not find compatible versions
Because rails >= 7.0.3.1, < 7.0.4 depends on activemodel = 7.0.3.1
and rails >= 7.0.2.3, < 7.0.3.1 depends on activemodel = 7.0.2.3,
rails >= 7.0.2.3, < 7.0.4 requires activemodel = 7.0.2.3 OR = 7.0.3.1.
And because every version of activemodel depends on activesupport = 6.0.4,
rails >= 7.0.2.3, < 7.0.4 requires activesupport = 6.0.4.
Because rails >= 7.0.3.1, < 7.0.4 depends on activesupport = 7.0.3.1
and rails >= 7.0.2.3, < 7.0.3.1 depends on activesupport = 7.0.2.3,
rails >= 7.0.2.3, < 7.0.4 requires activesupport = 7.0.2.3 OR = 7.0.3.1.
Thus, rails >= 7.0.2.3, < 7.0.4 cannot be used.
And because rails >= 7.0.4 depends on activemodel = 7.0.4,
rails >= 7.0.2.3 requires activemodel = 7.0.4.
So, because activemodel = 7.0.4 could not be found in rubygems repository https://gem.repo4/ or installed locally
and Gemfile depends on rails >= 7.0.2.3,
version solving has failed.
ERR
expect(err).to eq(expected_error)
end
it "does not accidentally resolves to prereleases" do