Load user installed RubyGems plugins.

This commit is contained in:
Vít Ondruch 2021-08-24 18:23:20 +02:00
parent 1170d812fe
commit 11a27766bd
2 changed files with 66 additions and 0 deletions

View File

@ -142,6 +142,9 @@ Patch6: ruby-2.7.0-Initialize-ABRT-hook.patch
# hardening features of glibc (rhbz#1361037). # hardening features of glibc (rhbz#1361037).
# https://bugs.ruby-lang.org/issues/12666 # https://bugs.ruby-lang.org/issues/12666
Patch9: ruby-2.3.1-Rely-on-ldd-to-detect-glibc.patch Patch9: ruby-2.3.1-Rely-on-ldd-to-detect-glibc.patch
# Load user installed RubyGems plugins.
# https://github.com/rubygems/rubygems/issues/4823
Patch10: rubygems-3.2.26-Also-load-user-installed-rubygems-plugins.patch
# Fix DWARF5 support. # Fix DWARF5 support.
# https://bugzilla.redhat.com/show_bug.cgi?id=1920533 # https://bugzilla.redhat.com/show_bug.cgi?id=1920533
# https://bugs.ruby-lang.org/issues/17585 # https://bugs.ruby-lang.org/issues/17585
@ -605,6 +608,7 @@ rm -rf ext/fiddle/libffi*
%patch5 -p1 %patch5 -p1
%patch6 -p1 %patch6 -p1
%patch9 -p1 %patch9 -p1
%patch10 -p1
%patch15 -p1 %patch15 -p1
%patch16 -p1 %patch16 -p1
%patch17 -p1 %patch17 -p1
@ -1368,6 +1372,7 @@ MSPECOPTS=""
%changelog %changelog
* Tue Aug 24 2021 Vít Ondruch <vondruch@redhat.com> - 3.0.2-152 * Tue Aug 24 2021 Vít Ondruch <vondruch@redhat.com> - 3.0.2-152
- Enable LTO. - Enable LTO.
- Load user installed RubyGems plugins.
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> * Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

View File

@ -0,0 +1,61 @@
From 82960c262fea081cdd3df14ebe573ff1c4925d0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Fri, 6 Aug 2021 12:21:23 +0200
Subject: [PATCH] Also load user installed rubygems plugins
---
lib/rubygems.rb | 4 +++-
test/rubygems/test_gem.rb | 25 +++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index a631cde8bf8..17881e2e0e9 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1063,7 +1063,9 @@ def self.load_plugin_files(plugins) # :nodoc:
# 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 0d4b1571ca7..da154dac75b 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1581,6 +1581,31 @@ def test_load_plugins
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