ruby/rubygems-3.2.7-Generate-plugin-wrappers-with-relative-requires.patch

48 lines
1.8 KiB
Diff
Raw Normal View History

From db4157e9aa7b7f720ee06fb866b53ad11879c016 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Mon, 25 Jan 2021 15:40:26 +0100
Subject: [PATCH] Generate plugin wrappers with relative requires
It shouldn't change behaviour and it fixes broken wrappers generated
with `--build-root` flag is used.
---
lib/rubygems/installer_uninstaller_utils.rb | 7 ++++++-
test/rubygems/test_gem_installer.rb | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/rubygems/installer_uninstaller_utils.rb b/lib/rubygems/installer_uninstaller_utils.rb
index e81ed4cba38..2c8b7c635e1 100644
--- a/lib/rubygems/installer_uninstaller_utils.rb
+++ b/lib/rubygems/installer_uninstaller_utils.rb
@@ -6,11 +6,16 @@
module Gem::InstallerUninstallerUtils
def regenerate_plugins_for(spec, plugins_dir)
+ plugins = spec.plugins
+ return if plugins.empty?
+
+ require 'pathname'
+
spec.plugins.each do |plugin|
plugin_script_path = File.join plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}"
File.open plugin_script_path, 'wb' do |file|
- file.puts "require '#{plugin}'"
+ file.puts "require_relative '#{Pathname.new(plugin).relative_path_from(Pathname.new(plugins_dir))}'"
end
verbose plugin_script_path
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 4ce7e92442a..5652d863316 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -821,6 +821,8 @@ def test_generate_plugins_with_build_root
assert !File.exist?(system_path), 'plugin written incorrect written to system plugins_dir'
assert File.exist?(build_root_path), 'plugin not written to build_root'
+
+ refute_includes File.read(build_root_path), build_root
end
def test_keeps_plugins_up_to_date