diff options
author | なつき <i@ntk.me> | 2023-03-16 18:09:45 -0700 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-03-23 17:18:49 +0900 |
commit | e46d473396401f8f320b4a5b8f638630ab42fa4c (patch) | |
tree | 8f1637b2d7a0463b7f4877093ffecb67a5be8e39 | |
parent | f8ecf145cee5a2af4cf48a2c0b6bf600886b8b96 (diff) |
Make sure native extensions are loaded correctly in ext_conf builder
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7582
-rw-r--r-- | lib/rubygems/ext/ext_conf_builder.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index cabafaed05..f8fed2a8bf 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -21,9 +21,23 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder destdir = ENV["DESTDIR"] + # 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 require "shellwords" - cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../..", __dir__) << File.basename(extension) + cmd = Gem.ruby.shellsplit + cmd.push(*load_path) + cmd << File.basename(extension) cmd.push(*args) run(cmd, results, class_name, extension_dir) do |s, r| |