[rubygems/rubygems] Revert RubyGems plugins getting loaded on Bundler.require

These changes were included when adding bundler plugin hooks for
`Bundler.require`, but they seem completely unrelated to that feature,
and have caused several issues.

https://github.com/rubygems/rubygems/commit/8d56551dcf
This commit is contained in:
David Rodríguez 2025-01-14 07:41:25 +01:00 committed by Hiroshi SHIBATA
parent 10e7e92bad
commit e7de621b5a
4 changed files with 31 additions and 31 deletions

View File

@ -212,7 +212,6 @@ module Bundler
# Bundler.require(:test) # requires second_gem
#
def require(*groups)
load_plugins
setup(*groups).require(*groups)
end
@ -576,23 +575,6 @@ module Bundler
@feature_flag ||= FeatureFlag.new(VERSION)
end
def load_plugins(definition = Bundler.definition)
return if defined?(@load_plugins_ran)
Bundler.rubygems.load_plugins
requested_path_gems = definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.flat_map do |spec|
spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
end
Bundler.rubygems.load_plugin_files(path_plugin_files)
Bundler.rubygems.load_env_plugins
@load_plugins_ran = true
end
def reset!
reset_paths!
Plugin.reset!

View File

@ -79,7 +79,7 @@ module Bundler
if @definition.setup_domain!(options)
ensure_specs_are_compatible!
Bundler.load_plugins(@definition)
load_plugins
end
install(options)
@ -209,6 +209,20 @@ module Bundler
Bundler.settings.processor_count
end
def load_plugins
Gem.load_plugins
requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.flat_map do |spec|
spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
end
Gem.load_plugin_files(path_plugin_files)
Gem.load_env_plugins
end
def ensure_specs_are_compatible!
@definition.specs.each do |spec|
unless spec.matches_current_ruby?

View File

@ -134,18 +134,6 @@ module Bundler
loaded_gem_paths.flatten
end
def load_plugins
Gem.load_plugins
end
def load_plugin_files(plugin_files)
Gem.load_plugin_files(plugin_files)
end
def load_env_plugins
Gem.load_env_plugins
end
def ui=(obj)
Gem::DefaultUserInteraction.ui = obj
end

View File

@ -431,6 +431,22 @@ RSpec.describe "Bundler.require" do
expect(out).to eq("WIN")
end
it "does not load plugins" do
install_gemfile <<-G
source "https://gem.repo1"
gem "myrack"
G
create_file "plugins/rubygems_plugin.rb", "puts 'FAIL'"
run <<~R, env: { "RUBYLIB" => rubylib.unshift(bundled_app("plugins").to_s).join(File::PATH_SEPARATOR) }
Bundler.require
puts "WIN"
R
expect(out).to eq("WIN")
end
it "does not extract gemspecs from application cache packages" do
gemfile <<-G
source "https://gem.repo1"