bc5cb60
From c5197b2ab35ba389f48918e0c773b43b6dca2fa5 Mon Sep 17 00:00:00 2001
bc5cb60
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
bc5cb60
Date: Fri, 7 Feb 2020 17:16:05 +0100
bc5cb60
Subject: [PATCH 1/3] Tweaks to get test passing more reliably
bc5cb60
bc5cb60
---
bc5cb60
 test/rubygems/test_require.rb | 6 ++++--
bc5cb60
 1 file changed, 4 insertions(+), 2 deletions(-)
bc5cb60
bc5cb60
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
bc5cb60
index 7cffbfa7fe..67c55416d4 100644
bc5cb60
--- a/test/rubygems/test_require.rb
bc5cb60
+++ b/test/rubygems/test_require.rb
bc5cb60
@@ -567,18 +567,20 @@ def util_install_extension_file(name)
bc5cb60
     write_file File.join(@tempdir, "extconf.rb") do |io|
bc5cb60
       io.write <<-RUBY
bc5cb60
         require "mkmf"
bc5cb60
+        CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
bc5cb60
         create_makefile("#{name}")
bc5cb60
       RUBY
bc5cb60
     end
bc5cb60
 
bc5cb60
     write_file File.join(@tempdir, "#{name}.c") do |io|
bc5cb60
       io.write <<-C
bc5cb60
-        #include <ruby.h>
bc5cb60
         void Init_#{name}() { }
bc5cb60
       C
bc5cb60
     end
bc5cb60
 
bc5cb60
-    spec.files += ["extconf.rb", "#{name}.c"]
bc5cb60
+    write_file File.join(@tempdir, "depend")
bc5cb60
+
bc5cb60
+    spec.files += ["extconf.rb", "depend", "#{name}.c"]
bc5cb60
 
bc5cb60
     so = File.join(spec.gem_dir, "#{name}.#{RbConfig::CONFIG["DLEXT"]}")
bc5cb60
     refute_path_exists so
bc5cb60
bc5cb60
From 7bfd7319cd751837c3ccaf1d97b02846eaaf39d5 Mon Sep 17 00:00:00 2001
bc5cb60
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
bc5cb60
Date: Tue, 11 Feb 2020 11:56:06 +0100
bc5cb60
Subject: [PATCH 2/3] Fix bug bug calculating $LOAD_PATH's to check in
bc5cb60
 `require`
bc5cb60
bc5cb60
In `Gem.load_path_insert_index` is not set, we end up having
bc5cb60
`$LOAD_PATH[0...-1]`, unintentionally skipping the last $LOAD_PATH entry
bc5cb60
from the check.
bc5cb60
bc5cb60
The correct thing to do in that case is to not even try since we have no
bc5cb60
way of distinguisng default LOAD_PATH entries from those added with -I.
bc5cb60
---
bc5cb60
 lib/rubygems/core_ext/kernel_require.rb | 5 ++++-
bc5cb60
 1 file changed, 4 insertions(+), 1 deletion(-)
bc5cb60
bc5cb60
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
bc5cb60
index 369f2c743e..a8d170f13a 100644
bc5cb60
--- a/lib/rubygems/core_ext/kernel_require.rb
bc5cb60
+++ b/lib/rubygems/core_ext/kernel_require.rb
bc5cb60
@@ -44,7 +44,10 @@ def require(path)
bc5cb60
     resolved_path = begin
bc5cb60
       rp = nil
bc5cb60
       Gem.suffixes.each do |s|
bc5cb60
-        $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
bc5cb60
+        load_path_insert_index = Gem.load_path_insert_index
bc5cb60
+        break unless load_path_insert_index
bc5cb60
+
bc5cb60
+        $LOAD_PATH[0...load_path_insert_index].each do |lp|
bc5cb60
           safe_lp = lp.dup.tap(&Gem::UNTAINT)
bc5cb60
           begin
bc5cb60
             if File.symlink? safe_lp # for backward compatibility
bc5cb60
bc5cb60
From 4fc0ab21c0f7713829abb522ce3b6d8e24c126b3 Mon Sep 17 00:00:00 2001
bc5cb60
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
bc5cb60
Date: Fri, 14 Feb 2020 02:03:04 +0100
bc5cb60
Subject: [PATCH 3/3] Exclude empty suffix from `-I` require loop
bc5cb60
bc5cb60
---
bc5cb60
 lib/rubygems/core_ext/kernel_require.rb | 2 +-
bc5cb60
 1 file changed, 1 insertion(+), 1 deletion(-)
bc5cb60
bc5cb60
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
bc5cb60
index a8d170f13a..9712fb6ac0 100644
bc5cb60
--- a/lib/rubygems/core_ext/kernel_require.rb
bc5cb60
+++ b/lib/rubygems/core_ext/kernel_require.rb
bc5cb60
@@ -43,7 +43,7 @@ def require(path)
bc5cb60
     # https://github.com/rubygems/rubygems/pull/1868
bc5cb60
     resolved_path = begin
bc5cb60
       rp = nil
bc5cb60
-      Gem.suffixes.each do |s|
bc5cb60
+      Gem.suffixes[1..-1].each do |s|
bc5cb60
         load_path_insert_index = Gem.load_path_insert_index
bc5cb60
         break unless load_path_insert_index
bc5cb60