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
This commit is contained in:
Hiroshi SHIBATA 2023-11-02 15:46:42 +09:00
parent 7523ede7ba
commit e10f7c9d5b
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -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|