Skip to content

Commit

Permalink
Handle Ruby 3.1 eval location change
Browse files Browse the repository at this point in the history
Ref: ruby/ruby#4519

On Ruby 3.1, `Backtrace::Location#absolute_path` returns `nil` if the
code was loaded with eval. That same PR made `require_relative` fallback
to `Backtrace::Location#path` in such case, so we're doing the same.
  • Loading branch information
byroot committed Aug 2, 2021
1 parent 9562e21 commit 0d64e7e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bootsnap/load_path_cache/core_ext/kernel_require.rb
Expand Up @@ -47,8 +47,9 @@ def require(path)

alias_method(:require_relative_without_bootsnap, :require_relative)
def require_relative(path)
location = caller_locations(1..1).first
realpath = Bootsnap::LoadPathCache.realpath_cache.call(
caller_locations(1..1).first.absolute_path, path
location.absolute_path || location.path, path
)
require(realpath)
end
Expand Down

0 comments on commit 0d64e7e

Please sign in to comment.