summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-27 18:31:51 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 14:13:29 +0900
commit1039c32de6ac27400b2cc9eca2b0cd382ddcfbdd (patch)
tree5fe362aa72a7cd34321d35d96931a6c27566d54c
parent43daf4d288926c90af716ff0d8306501fd1b3a13 (diff)
[rubygems/rubygems] Simplify nested require exceptions
https://github.com/rubygems/rubygems/commit/7fbef2f0e3
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3092
-rw-r--r--lib/rubygems/core_ext/kernel_require.rb3
-rw-r--r--test/rubygems/test_kernel.rb19
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index a8d170f13a..ed24111bd5 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -156,8 +156,7 @@ module Kernel
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 b9f9b5e254..daf9b57d7c 100644
--- a/test/rubygems/test_kernel.rb
+++ b/test/rubygems/test_kernel.rb
@@ -91,6 +91,25 @@ class TestKernel < Gem::TestCase
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'