diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-08-06 12:21:23 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-08-31 19:06:14 +0900 |
commit | 9fa5c4cd0721f720282dfc9efe5657b136c7e99b (patch) | |
tree | fb2e1f497b5f9fbd48907bb9f8b5449b113c17b5 | |
parent | 21db5876caeb8f67dfef6f9010e4ab7639d39c1b (diff) | |
download | ruby-9fa5c4cd0721f720282dfc9efe5657b136c7e99b.tar.gz |
[rubygems/rubygems] Also load user installed rubygems plugins
https://github.com/rubygems/rubygems/commit/82960c262f
-rw-r--r-- | lib/rubygems.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem.rb | 25 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index a631cde8bf..17881e2e0e 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -1050,7 +1050,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # Find rubygems plugin files in the standard location and load them def self.load_plugins - load_plugin_files Gem::Util.glob_files_in_dir("*#{Gem.plugin_suffix_pattern}", plugindir) + Gem.path.each do |gem_path| + load_plugin_files Gem::Util.glob_files_in_dir("*#{Gem.plugin_suffix_pattern}", plugindir(gem_path)) + end end ## diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 0d4b1571ca..da154dac75 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1578,6 +1578,31 @@ class TestGem < Gem::TestCase assert_equal %w[plugin], PLUGINS_LOADED end + def test_load_user_installed_plugins + plugin_path = File.join "lib", "rubygems_plugin.rb" + + Dir.chdir @tempdir do + FileUtils.mkdir_p 'lib' + File.open plugin_path, "w" do |fp| + fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end" + end + + foo = util_spec 'foo', '1' do |s| + s.files << plugin_path + end + + install_gem_user foo + end + + Gem.paths = { "GEM_PATH" => [Gem.dir, Gem.user_dir].join(File::PATH_SEPARATOR) } + + gem 'foo' + + Gem.load_plugins + + assert_equal %w[plugin], PLUGINS_LOADED + end + def test_load_env_plugins with_plugin('load') { Gem.load_env_plugins } assert_equal :loaded, TEST_PLUGIN_LOAD rescue nil |