[rubygems/rubygems] Avoid more warnings when using RubyGems with old Bundler

We were only avoiding them when the RUBYGEMS_GEMDEPS variable is used.
Avoid the warnings in general, whenever the entrypoint to Bundler is
`require`.

8683faef36
This commit is contained in:
David Rodríguez 2025-07-10 19:46:39 +02:00 committed by Hiroshi SHIBATA
parent a93c684077
commit c3d41492e1
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
2 changed files with 7 additions and 6 deletions

View file

@ -640,9 +640,8 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Load Bundler extensions to RubyGems, making sure to avoid redefinition # Load Bundler extensions to RubyGems, making sure to avoid redefinition
# warnings in platform constants # warnings in platform constants
def self.load_bundler_extensions def self.load_bundler_extensions(version)
require "bundler/version" return unless version <= "2.6.9"
return if Bundler::VERSION >= "2.6.9"
previous_platforms = {} previous_platforms = {}
@ -1169,7 +1168,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path) ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
require_relative "rubygems/user_interaction" require_relative "rubygems/user_interaction"
Gem.load_bundler_extensions
require "bundler" require "bundler"
begin begin
Gem::DefaultUserInteraction.use_ui(ui) do Gem::DefaultUserInteraction.use_ui(ui) do

View file

@ -64,8 +64,11 @@ module Kernel
rp rp
end end
Kernel.send(:gem, name, Gem::Requirement.default_prerelease) unless next if resolved_path
resolved_path
Kernel.send(:gem, name, Gem::Requirement.default_prerelease)
Gem.load_bundler_extensions(Gem.loaded_specs[name].version) if name == "bundler"
next next
end end