diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2026-05-07 19:08:22 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-05-08 06:43:42 +0000 |
| commit | 3e1a5faa1a7c02aa2ac8dd07dc98b74c55c130e4 (patch) | |
| tree | b433ebe486ba47ee668a652310c7c51d17260708 | |
| parent | 139e281962b8a3859b9c338c99ede86bfc61c2ce (diff) | |
[ruby/rubygems] Honor metadata overrides in MatchMetadata
matches_current_ruby? / matches_current_rubygems? now look up the
current Definition's overrides via Bundler.overrides and apply them
before checking against the runtime Ruby/RubyGems version. This
covers Installer#ensure_specs_are_compatible! and the materialize-
layer choose_compatible / SpecSet#valid? checks uniformly without
plumbing overrides through every materialization site.
When no Definition is set yet (e.g. RubyGems-side calls outside a
Bundler.definition block), Bundler.overrides returns an empty list
and the methods fall through to their original behavior.
https://github.com/ruby/rubygems/commit/afe9313b6e
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| -rw-r--r-- | lib/bundler.rb | 5 | ||||
| -rw-r--r-- | lib/bundler/match_metadata.rb | 20 |
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 12dde90fc5..c686b106c7 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -244,6 +244,11 @@ module Bundler Bundler.settings[:deployment] end + def overrides + return [] unless defined?(@definition) && @definition + @definition.overrides + end + def locked_gems @locked_gems ||= if defined?(@definition) && @definition diff --git a/lib/bundler/match_metadata.rb b/lib/bundler/match_metadata.rb index 6fd2994a85..75b0e4357c 100644 --- a/lib/bundler/match_metadata.rb +++ b/lib/bundler/match_metadata.rb @@ -7,11 +7,11 @@ module Bundler end def matches_current_ruby? - @required_ruby_version.satisfied_by?(Gem.ruby_version) + effective_required_ruby_version.satisfied_by?(Gem.ruby_version) end def matches_current_rubygems? - @required_rubygems_version.satisfied_by?(Gem.rubygems_version) + effective_required_rubygems_version.satisfied_by?(Gem.rubygems_version) end def expanded_dependencies @@ -26,5 +26,21 @@ module Bundler Gem::Dependency.new("#{name}\0", requirement) end + + private + + def effective_required_ruby_version + apply_metadata_override(@required_ruby_version, :required_ruby_version) + end + + def effective_required_rubygems_version + apply_metadata_override(@required_rubygems_version, :required_rubygems_version) + end + + def apply_metadata_override(requirement, field) + override = Override.find_for(Bundler.overrides, name, field) + return requirement unless override + override.apply_to(requirement) + end end end |
