diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-08-25 15:53:26 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-08-25 15:57:53 +0900 |
commit | f7359e112a2834e7360dcee3836508d2031b7e72 (patch) | |
tree | 7845544193d45d9ce6e979392ed42881124f76d1 | |
parent | 70272ca65c59f787e48c219c8946b22ce310fef0 (diff) | |
download | ruby-f7359e112a2834e7360dcee3836508d2031b7e72.tar.gz |
Suggest to add bundled gems into gemspec if 3rd party gem try to load gem from Gem::BUNDLED_GEMS::SINCE
[Feature #19846]
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 7c281e5137..060be66c8c 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -254,8 +254,20 @@ module Bundler "inline Gemfile" end be = RUBY_VERSION < ::Gem::BUNDLED_GEMS::SINCE[name] ? "will be" : "is" - warn "#{name} #{be} not part of the default gems since Ruby #{::Gem::BUNDLED_GEMS::SINCE[name]}." \ - " Add it to your #{target_file}.", uplevel: 1 + message = "#{name} #{be} not part of the default gems since Ruby #{::Gem::BUNDLED_GEMS::SINCE[name]}." \ + " Add #{name} to your #{target_file}." + location = caller_locations(1,1)[0]&.path + if File.file?(location) && !location.start_with?(Gem::BUNDLED_GEMS::LIBDIR) + caller_gem = nil + Gem.path.each do |path| + if location =~ /#{path}\/gems\/([\w\-\.]+)/ + caller_gem = $1 + break + end + end + message += " Also contact author of #{caller_gem} to add #{name} into its gemspec." + end + warn message, uplevel: 1 end end kernel_class.send(:no_warning_require, file) |