Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Package#normalized_required_rubygems_version
normalized_required_rubygems_version(ruby_abi)
lib/rubygems/package.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/package.rb, line 758
def normalized_required_rubygems_version(ruby_abi)
minimum = Gem::Requirement.new(MINIMUM_RUBYGEMS_VERSION)
existing = @spec.required_rubygems_version
return minimum if existing.nil? || existing == Gem::Requirement.default
floor = minimum.requirements.first.last
if excludes_rubygems_floor?(existing, floor)
raise ArgumentError,
"Cannot build gem for Ruby ABI #{ruby_abi} because required_rubygems_version is set to #{existing}, " \
"which excludes RubyGems #{MINIMUM_RUBYGEMS_VERSION} required to install content addressable gems. " \
"Please remove or loosen the conflicting constraint."
end
return existing if satisfies_rubygems_floor?(existing, floor)
preserved = existing.requirements.filter_map do |op, version|
"#{op} #{version}" if ["~>", "<", "<=", "!="].include?(op)
end
normalized = Gem::Requirement.new([MINIMUM_RUBYGEMS_VERSION, *preserved])
alert_warning \
"required_rubygems_version was changed from \"#{existing}\" to \"#{normalized}\" for this build " \
"because content addressable gems can only be installed by RubyGems #{MINIMUM_RUBYGEMS_VERSION}."
normalized
end
The required_rubygems_version for a content-addressable build: the spec’s requirement raised to at least MINIMUM_RUBYGEMS_VERSION, warning if it had to be changed. Raises if the requirement excludes every version satisfying that floor, since no RubyGems could install the built gem.