From 331fe6a88f96d9f986da55e003e896c2bc181db0 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 10 Jul 2020 21:51:45 +0200 Subject: [rubygems/rubygems] Ignore internal frames in RubyGems' Kernel#warn * See https://github.com/oracle/truffleruby/issues/2046 * `' # where #warn is called core/kernel.rb:234:in `gem_original_require' # not skipped by RubyGems' warn, skipped by the Ruby impl rubygems/core_ext/kernel_require.rb:54:in `require' # not skipped by the Ruby impl's warn, what would be shown without this fix warn.rb:1:in `
' # what would be correct warn.rb is require "warnee" warnee.rb is puts caller_locations(0), nil warn "oops", uplevel: 1 https://github.com/rubygems/rubygems/commit/7c838f7419 --- lib/rubygems/core_ext/kernel_warn.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/rubygems') diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb index 8b73902d3b..e10a845b98 100644 --- a/lib/rubygems/core_ext/kernel_warn.rb +++ b/lib/rubygems/core_ext/kernel_warn.rb @@ -4,7 +4,7 @@ if RUBY_VERSION >= "2.5" module Kernel - path = "#{__dir__}/" # Frames to be skipped start with this path. + rubygems_path = "#{__dir__}/" # Frames to be skipped start with this path. original_warn = method(:warn) @@ -38,7 +38,8 @@ if RUBY_VERSION >= "2.5" start += 1 - unless loc.path.start_with?(path) + path = loc.path + unless path.start_with?(rubygems_path) or path.start_with?('