File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -254,8 +254,20 @@ def replace_require(specs)
254
254
"inline Gemfile"
255
255
end
256
256
be = RUBY_VERSION < ::Gem ::BUNDLED_GEMS ::SINCE [ name ] ? "will be" : "is"
257
- warn "#{ name } #{ be } not part of the default gems since Ruby #{ ::Gem ::BUNDLED_GEMS ::SINCE [ name ] } ." \
258
- " Add it to your #{ target_file } ." , uplevel : 1
257
+ message = "#{ name } #{ be } not part of the default gems since Ruby #{ ::Gem ::BUNDLED_GEMS ::SINCE [ name ] } ." \
258
+ " Add #{ name } to your #{ target_file } ."
259
+ location = caller_locations ( 1 , 1 ) [ 0 ] &.path
260
+ if File . file? ( location ) && !location . start_with? ( Gem ::BUNDLED_GEMS ::LIBDIR )
261
+ caller_gem = nil
262
+ Gem . path . each do |path |
263
+ if location =~ /#{ path } \/ gems\/ ([\w \- \. ]+)/
264
+ caller_gem = $1
265
+ break
266
+ end
267
+ end
268
+ message += " Also contact author of #{ caller_gem } to add #{ name } into its gemspec."
269
+ end
270
+ warn message , uplevel : 1
259
271
end
260
272
end
261
273
kernel_class . send ( :no_warning_require , file )
You can’t perform that action at this time.
0 commit comments