aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/core_ext/kernel_require.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-24 07:39:24 +0100
committerGitHub <noreply@github.com>2020-03-24 15:39:24 +0900
commit96064e6f1ce100a37680dc8f9509f06b3350e9c8 (patch)
tree798b59f015cb82ee3cd0427f80584032175829ba /lib/rubygems/core_ext/kernel_require.rb
parent930b012ad96bfb0bd12446b89407120744ef92eb (diff)
downloadruby-96064e6f1ce100a37680dc8f9509f06b3350e9c8.tar.gz
Sync rubygems with current master (#2889)
Diffstat (limited to 'lib/rubygems/core_ext/kernel_require.rb')
-rw-r--r--lib/rubygems/core_ext/kernel_require.rb31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 60f4d18712..a8d170f13a 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -43,18 +43,21 @@ module Kernel
# https://github.com/rubygems/rubygems/pull/1868
resolved_path = begin
rp = nil
- $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
- safe_lp = lp.dup.tap(&Gem::UNTAINT)
- begin
- if File.symlink? safe_lp # for backward compatibility
- next
+ Gem.suffixes.each do |s|
+ load_path_insert_index = Gem.load_path_insert_index
+ break unless load_path_insert_index
+
+ $LOAD_PATH[0...load_path_insert_index].each do |lp|
+ safe_lp = lp.dup.tap(&Gem::UNTAINT)
+ begin
+ if File.symlink? safe_lp # for backward compatibility
+ next
+ end
+ rescue SecurityError
+ RUBYGEMS_ACTIVATION_MONITOR.exit
+ raise
end
- rescue SecurityError
- RUBYGEMS_ACTIVATION_MONITOR.exit
- raise
- end
- Gem.suffixes.each do |s|
full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
if File.file?(full_path)
rp = full_path
@@ -67,12 +70,8 @@ module Kernel
end
if resolved_path
- begin
- RUBYGEMS_ACTIVATION_MONITOR.exit
- return gem_original_require(resolved_path)
- rescue LoadError
- RUBYGEMS_ACTIVATION_MONITOR.enter
- end
+ RUBYGEMS_ACTIVATION_MONITOR.exit
+ return gem_original_require(resolved_path)
end
if spec = Gem.find_unresolved_default_spec(path)