diff options
Diffstat (limited to 'lib/rubygems/ext/ext_conf_builder.rb')
-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| |