From d4603e05e363f712e8856365ead62cd2736e6387 Mon Sep 17 00:00:00 2001 From: Nicolas Rodriguez Date: Fri, 18 Oct 2024 01:24:57 +0200 Subject: [PATCH] Fallback to Thread::Backtrace::Location#path when #absolute_path is nil --- lib/derailed_benchmarks/core_ext/kernel_require.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/derailed_benchmarks/core_ext/kernel_require.rb b/lib/derailed_benchmarks/core_ext/kernel_require.rb index 2983966..5f83377 100644 --- a/lib/derailed_benchmarks/core_ext/kernel_require.rb +++ b/lib/derailed_benchmarks/core_ext/kernel_require.rb @@ -35,7 +35,8 @@ def require_relative(file) if Pathname.new(file).absolute? require file else - require File.expand_path("../#{file}", caller_locations(1, 1)[0].absolute_path) + path = caller_locations(1, 1)[0].absolute_path || caller_locations(1, 1)[0].path + require File.expand_path("../#{file}", path) end end