summaryrefslogtreecommitdiff
path: root/lib/rubygems/core_ext
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-08-17 08:54:05 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-08-17 15:12:45 +0900
commitdd16f8524c44f8802e634af2577fe5a149cd740e (patch)
tree546f8eea794e3d09b20b7fecf5d914fea80d1eca /lib/rubygems/core_ext
parent9d20d2b0f5096fab210464f9e16d876f9c5d319f (diff)
Revert "Revert "[rubygems/rubygems] [Require] Ensure -I beats a default gem""
This reverts commit 75d29db8f965893bb6ab38b9008abc80cdda246e.
Diffstat (limited to 'lib/rubygems/core_ext')
-rwxr-xr-xlib/rubygems/core_ext/kernel_require.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 8c85ef7..5986e35 100755
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -36,6 +36,26 @@ module Kernel
path = path.to_path if path.respond_to? :to_path
+ resolved_path = begin
+ rp = nil
+ $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
+ Gem.suffixes.each do |s|
+ full_path = File.expand_path(File.join(lp, "#{path}#{s}").untaint)
+ if File.file?(full_path)
+ rp = full_path
+ break
+ end
+ end
+ break if rp
+ end
+ rp
+ end
+
+ if resolved_path
+ RUBYGEMS_ACTIVATION_MONITOR.exit
+ return gem_original_require(resolved_path)
+ end
+
if spec = Gem.find_unresolved_default_spec(path)
begin
Kernel.send(:gem, spec.name, "#{Gem::Requirement.default}.a")