aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundled_gems.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-11-02 15:46:42 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-11-02 15:48:34 +0900
commite10f7c9d5b7c3097cd0d7bc3b7b7bbd2078c02cc (patch)
tree14e12eecfb45edd07f9d80b0d3c3d788ac246bc5 /lib/bundled_gems.rb
parent7523ede7ba0a5c1487bb53b3169f1a2cbc13152d (diff)
downloadruby-e10f7c9d5b7c3097cd0d7bc3b7b7bbd2078c02cc.tar.gz
Fix to detect gem name logic. It's mistake to migrate bundled_gems.rb from rubygems_integration.rb
https://github.com/ioquatix/bake/pull/15#issuecomment-1777985097
Diffstat (limited to 'lib/bundled_gems.rb')
-rw-r--r--lib/bundled_gems.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb
index 6fff10fdcf..a00de692ea 100644
--- a/lib/bundled_gems.rb
+++ b/lib/bundled_gems.rb
@@ -96,7 +96,10 @@ module Gem::BUNDLED_GEMS
if defined?(Bundler)
msg += " Add #{gem} to your Gemfile or gemspec."
- location = caller_locations(2,2)[0]&.path
+ # We detect the gem name from caller_locations. We need to skip 2 frames like:
+ # lib/ruby/3.3.0+0/bundled_gems.rb:90:in `warning?'",
+ # lib/ruby/3.3.0+0/bundler/rubygems_integration.rb:247:in `block (2 levels) in replace_require'",
+ location = caller_locations(3,3)[0]&.path
if File.file?(location) && !location.start_with?(Gem::BUNDLED_GEMS::LIBDIR)
caller_gem = nil
Gem.path.each do |path|