Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Resolver#incompatibilities_for
incompatibilities_for(package, version)
lib/rubygems/resolver.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/resolver.rb, line 272
def incompatibilities_for(package, version)
package_deps = @cached_dependencies[package]
sorted_versions = @sorted_versions[package]
package_deps[version].filter_map do |dep_package_name, dep_constraint|
dep_package = dep_constraint.package
low = high = @version_to_index[package][version]
# find version low such that all >= low share the same dep
while low > 0 &&
package_deps[sorted_versions[low - 1]][dep_package_name] == dep_constraint
low -= 1
end
low =
if low == 0
nil
else
sorted_versions[low]
end
# find version high such that all < high share the same dep
while high < sorted_versions.length &&
package_deps[sorted_versions[high]][dep_package_name] == dep_constraint
high += 1
end
high =
if high == sorted_versions.length
nil
else
sorted_versions[high]
end
range = Gem::PubGrub::VersionRange.new(min: low, max: high, include_min: !low.nil?)
self_constraint = Gem::PubGrub::VersionConstraint.new(package, range: range)
# No specs anywhere means an unknown package. Check @unfiltered_specs, not
# the filtered set, so a dep filtered out by platform/Ruby/prerelease falls
# through to NoVersions for proper hints instead. The band-scoped
# self_constraint lets clean sibling versions still resolve via backtracking.
if @unfiltered_specs[dep_package_name].empty?
cause = Gem::PubGrub::Incompatibility::InvalidDependency.new(dep_package, dep_constraint)
self_term = Gem::PubGrub::Term.new(self_constraint, true)
# PubGrub's default InvalidDependency rendering drops the version
# requirement ("depends on unknown package bar"). Supply a custom
# explanation so the missing dependency's constraint is preserved
# ("depends on bar = 0.5 which could not be found in any repository"),
# matching Molinillo's diagnostics.
return [Gem::PubGrub::Incompatibility.new(
[self_term],
cause: cause,
custom_explanation: "#{self_term.to_s(allow_every: true)} depends on #{dep_constraint} which could not be found in any repository"
)]
end
# An empty range means the requirement is self-contradictory (e.g. `> 2, < 1`).
if dep_constraint.range.empty?
return [Gem::Resolver::Incompatibility.new(
[Gem::PubGrub::Term.new(self_constraint, true)],
cause: Gem::PubGrub::Incompatibility::NoVersions.new(dep_constraint),
custom_explanation: "#{dep_package_name} cannot satisfy contradictory requirements #{dep_constraint.constraint_string}"
)]
end
Gem::PubGrub::Incompatibility.new(
[Gem::PubGrub::Term.new(self_constraint, true), Gem::PubGrub::Term.new(dep_constraint, false)],
cause: :dependency
)
end
end
No documentation available