[Bug #20450] Remove rubyarchdir from bootsnap paths

This commit is contained in:
Eugene Kenny 2024-04-24 12:10:48 +01:00 committed by Hiroshi SHIBATA
parent 01f6ea1583
commit 67dd9af17e
3 changed files with 20 additions and 2 deletions

View File

@ -101,8 +101,11 @@ module Gem::BUNDLED_GEMS
def self.warning?(name, specs: nil)
# name can be a feature name or a file path with String or Pathname
feature = File.path(name)
# bootsnap expand `require "csv"` to `require "#{LIBDIR}/csv.rb"`
name = feature.delete_prefix(LIBDIR).chomp(".rb").tr("/", "-")
# bootsnap expands `require "csv"` to `require "#{LIBDIR}/csv.rb"`,
# and `require "syslog"` to `require "#{ARCHDIR}/syslog.so"`.
name = feature.delete_prefix(ARCHDIR)
name.delete_prefix!(LIBDIR)
name.tr!("/", "-")
name.sub!(LIBEXT, "")
return if specs.include?(name)
_t, path = $:.resolve_feature_path(feature)

View File

@ -32,6 +32,10 @@ echo "* Show warning with bootsnap"
ruby test_warn_bootsnap.rb
echo
echo "* Show warning with bootsnap for gem with native extension"
ruby test_warn_bootsnap_rubyarchdir_gem.rb
echo
echo "* Show warning with zeitwerk"
ruby test_warn_zeitwerk.rb
echo

View File

@ -0,0 +1,11 @@
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "bootsnap", require: false
end
require 'bootsnap'
Bootsnap.setup(cache_dir: 'tmp/cache')
require 'syslog'