summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorなつき <i@ntk.me>2023-03-15 20:52:46 -0700
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-23 17:18:49 +0900
commitf8ecf145cee5a2af4cf48a2c0b6bf600886b8b96 (patch)
treeafc0c18fd51d802f4bebab76603eca913ace9b39
parenta757e21bc0ab1a9595ddad38e92f3941caf84d98 (diff)
Make sure native extensions are loaded correctly in rake builder
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7582
-rw-r--r--lib/rubygems/ext/rake_builder.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 282285b970..9a3f8ca65e 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -18,8 +18,20 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
require "shellwords"
rake = rake.shellsplit
else
+ # This is only needed when running rubygems test without a proper installation.
+ # Prepending it in a normal installation can cause problem with order of $LOAD_PATH.
+ # Therefore only add rubygems_load_path if it is not present in the default $LOAD_PATH.
+ rubygems_load_path = File.expand_path("../..", __dir__)
+ load_path =
+ case rubygems_load_path
+ when RbConfig::CONFIG["sitelibdir"], RbConfig::CONFIG["vendorlibdir"], RbConfig::CONFIG["rubylibdir"]
+ []
+ else
+ ["-I#{rubygems_load_path}"]
+ end
+
begin
- rake = [Gem.ruby, "-I#{File.expand_path("../..", __dir__)}", "-rrubygems", Gem.bin_path("rake", "rake")]
+ rake = [Gem.ruby, *load_path, "-rrubygems", Gem.bin_path("rake", "rake")]
rescue Gem::Exception
rake = [Gem.default_exec_format % "rake"]
end