[前][次][番号順一覧][スレッド一覧]

ruby-changes:61090

From: David <ko1@a...>
Date: Fri, 8 May 2020 14:14:01 +0900 (JST)
Subject: [ruby-changes:61090] 1039c32de6 (master): [rubygems/rubygems] Simplify nested require exceptions

https://git.ruby-lang.org/ruby.git/commit/?id=1039c32de6

From 1039c32de6ac27400b2cc9eca2b0cd382ddcfbdd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Fri, 27 Mar 2020 18:31:51 +0100
Subject: [rubygems/rubygems] Simplify nested require exceptions

https://github.com/rubygems/rubygems/commit/7fbef2f0e3

diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index a8d170f..ed24111 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -156,8 +156,7 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_require.rb#L156
     RUBYGEMS_ACTIVATION_MONITOR.enter
 
     begin
-      if load_error.message.start_with?("Could not find") or
-          (load_error.message.end_with?(path) and Gem.try_activate(path))
+      if load_error.message.end_with?(path) and Gem.try_activate(path)
         require_again = true
       end
     ensure
diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb
index b9f9b5e..daf9b57 100644
--- a/test/rubygems/test_kernel.rb
+++ b/test/rubygems/test_kernel.rb
@@ -91,6 +91,25 @@ class TestKernel < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_kernel.rb#L91
     refute $:.any? { |p| %r{a-1/bin} =~ p }
   end
 
+  def test_gem_failing_inside_require_doesnt_cause_double_exceptions
+    File.write("activate.rb", "gem('a', '= 999')\n")
+
+    require "open3"
+
+    output, _ = Open3.capture2e(
+      { "GEM_HOME" => Gem.paths.home },
+      Gem.ruby,
+      "-I",
+      File.expand_path("../../lib", __dir__),
+      "-r",
+      "./activate.rb"
+    )
+
+    load_errors = output.split("\n").select { |line| line.include?("Could not find")}
+
+    assert_equal 1, load_errors.size
+  end
+
   def test_gem_bundler
     quick_gem 'bundler', '1'
     quick_gem 'bundler', '2.a'
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]