ruby-changes:61550
From: David <ko1@a...>
Date: Fri, 5 Jun 2020 07:34:31 +0900 (JST)
Subject: [ruby-changes:61550] 5aa5aad48a (master): [rubygems/rubygems] Refactor `Gem.load_path_insert_index`
https://git.ruby-lang.org/ruby.git/commit/?id=5aa5aad48a From 5aa5aad48aa3effce60de3559d9bd107bfc9a91d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Tue, 19 May 2020 14:08:19 +0200 Subject: [rubygems/rubygems] Refactor `Gem.load_path_insert_index` https://github.com/rubygems/rubygems/commit/ae95885dff diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 9bf1c63..b03d747 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -590,7 +590,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L590 index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] - index + index || 0 end ## @@ -607,15 +607,8 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L607 def self.add_to_load_path(*paths) @activated_gem_paths = activated_gem_paths + paths.size - insert_index = load_path_insert_index - - if insert_index - # gem directories must come after -I and ENV['RUBYLIB'] - $LOAD_PATH.insert(insert_index, *paths) - else - # we are probably testing in core, -I and RUBYLIB don't apply - $LOAD_PATH.unshift(*paths) - end + # gem directories must come after -I and ENV['RUBYLIB'] + $LOAD_PATH.insert(Gem.load_path_insert_index, *paths) end @yaml_loaded = false diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb index 7625ce1..decf482 100644 --- a/lib/rubygems/core_ext/kernel_require.rb +++ b/lib/rubygems/core_ext/kernel_require.rb @@ -44,10 +44,7 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_require.rb#L44 resolved_path = begin rp = nil 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 - Gem.activated_gem_paths].each do |lp| + $LOAD_PATH[0...Gem.load_path_insert_index - Gem.activated_gem_paths].each do |lp| safe_lp = lp.dup.tap(&Gem::UNTAINT) begin if File.symlink? safe_lp # for backward compatibility -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/