File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -233,13 +233,15 @@ def replace_require(specs)
233233 kernel_class . send ( :define_method , :require ) do |file |
234234 name = file . tr ( "/" , "-" )
235235 if ( ::Gem ::BUNDLED_GEMS . keys - specs . to_a . map ( &:name ) ) . include? ( name )
236- target_file = begin
237- Bundler . default_gemfile . basename
238- rescue GemfileNotFound
239- "inline Gemfile"
240- end
241- warn "#{ name } is not part of the default gems since Ruby #{ ::Gem ::BUNDLED_GEMS [ file ] } ." \
242- " Add it to your #{ target_file } ."
236+ unless $LOADED_FEATURES. any? { |f | f . end_with? ( "#{ name } .rb" , "#{ name } .#{ RbConfig ::CONFIG [ 'DLEXT' ] } " ) }
237+ target_file = begin
238+ Bundler . default_gemfile . basename
239+ rescue GemfileNotFound
240+ "inline Gemfile"
241+ end
242+ warn "#{ name } is not part of the default gems since Ruby #{ ::Gem ::BUNDLED_GEMS [ file ] } ." \
243+ " Add it to your #{ target_file } ."
244+ end
243245 end
244246 kernel_class . send ( :no_warning_require , file )
245247 end
Original file line number Diff line number Diff line change @@ -1574,6 +1574,25 @@ def require(path)
15741574 expect ( err ) . to include ( "csv is not part of the default gems" )
15751575 end
15761576
1577+ it "don't warn with bundled gems when it's loaded twice" do
1578+ build_repo4 do
1579+ build_gem "rack"
1580+ end
1581+
1582+ install_gemfile <<-G
1583+ source "#{ file_uri_for ( gem_repo4 ) } "
1584+ gem "rack"
1585+ G
1586+
1587+ ruby <<-R
1588+ require 'csv'
1589+ require 'bundler/setup'
1590+ require 'csv'
1591+ R
1592+
1593+ expect ( err ) . to be_empty
1594+ end
1595+
15771596 it "don't warn with bundled gems when it's declared in Gemfile" do
15781597 build_repo4 do
15791598 build_gem "csv"
You can’t perform that action at this time.
0 commit comments