Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Resolver#resolve
resolve
lib/rubygems/resolver.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/resolver.rb, line 143
def resolve
# Pre-check: raise UnsatisfiableDependencyError for root deps with no
# platform match. We filter by platform ONLY here (not required_ruby_version
# / required_rubygems_version): a foreign-platform gem is genuinely "not
# found", but a gem that exists yet is incompatible with the running Ruby
# should flow through the solver to a DependencyResolutionError that names
# the Ruby requirement. That matches Bundler (which models Ruby as a
# synthetic dependency, so this surfaces as a solve failure) and gives a
# clearer message than the platform-oriented UnsatisfiableDependencyError.
@needed.each do |dep|
next if @soft_missing
dep_request = DependencyRequest.new(dep, nil)
all = @set.find_all(dep_request)
matching = select_local_platforms(all)
next unless matching.empty?
exc = Gem::UnsatisfiableDependencyError.new(dep_request, all)
exc.errors = @set.errors
raise exc
end
solver = Gem::PubGrub::VersionSolver.new(
source: self,
root: @root_package,
strategy: Gem::Resolver::Strategy.new(self),
logger: make_logger
)
result = solver.solve
# Convert to Array<ActivationRequest>
needed_by_name = @needed.group_by(&:name)
requests = result.filter_map do |package, version|
next if Gem::PubGrub::Package.root?(package)
spec = spec_for(package.to_s, version)
dep = needed_by_name[package.to_s]&.first || Gem::Dependency.new(package.to_s)
dep_request = DependencyRequest.new(dep, nil)
ActivationRequest.new(spec, dep_request)
end
@cooldown_skipped = cooldown_skipped_summary(requests) if @cooldown&.active?
requests
rescue Gem::PubGrub::SolveFailure => e
extended = extract_extended_explanation(e.incompatibility)
if extended
message = "#{e.explanation}\n\n#{extended}"
raise Gem::DependencyResolutionError, Struct.new(:explanation).new(message)
else
raise Gem::DependencyResolutionError, e
end
end
Proceed with resolution! Returns an array of ActivationRequest objects.
See also
#range_admits_prerelease?
#root_dependencies
#package_for
#spec_for
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0