This patch fixes an error when a default gem that will be migrated to
a bundled gem is loaded from `-r` option.
Problem
===
`bundle exec ruby -rostruct -e ''` unexpectedly raises the following error:
```console
$ ruby -v
ruby 3.4.0dev (2024-04-08T02:39:00Z master 6f7e8e278f) [arm64-darwin21]
$ bundle init && bundle install
$ bundle exec ruby -rostruct -e ''
/Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:111:in 'Gem::BUNDLED_GEMS.warning?': undefined method 'find' for nil (NoMethodError)
caller = caller_locations(3, 3).find {|c| c&.absolute_path}
^^^^^
from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:75:in 'block (2 levels) in Kernel#replace_require'
```
Solution
===
This patch uses a safe navigation operator to fix this problem. By this
change, the command will show the warning message correctly.
```console
$ bundle exec ruby -rostruct -e ''
warning: ostruct was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0. Add ostruct to your Gemfile or gemspec.
```
Followup: https://github.com/ruby/ruby/pull/10347
This avoid directly referencing bootsnap and zeitwerk, and also
handle other gems that may decorate `require`.
Before, when requiring "bigdecimal/math" in a Bundler context:
> /Users/deivid/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/bigdecimal/math.rb:2: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.
After:
> foo.rb:1: warning: bigdecimal/math is found in bigdecimal, which will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.
Before, when requiring "bigdecimal" in a Bundler context:
> foo.rb:1: warning: bigdecimal which will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.
After:
> foo.rb:1: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.