lib/bootsnap/load_path_cache/cache.rb in bootsnap-1.9.1 vs lib/bootsnap/load_path_cache/cache.rb in bootsnap-1.9.2

- old
+ new

@@ -42,18 +42,24 @@ end end.freeze # Try to resolve this feature to an absolute path without traversing the # loadpath. - def find(feature) + def find(feature, try_extensions: true) reinitialize if (@has_relative_paths && dir_changed?) || stale? feature = feature.to_s.freeze + return feature if absolute_path?(feature) - return expand_path(feature) if feature.start_with?('./') + + if feature.start_with?('./', '../') + return try_extensions ? expand_path(feature) : File.expand_path(feature).freeze + end + @mutex.synchronize do - x = search_index(feature) + x = search_index(feature, try_extensions: try_extensions) return x if x + return unless try_extensions # Ruby has some built-in features that require lies about. # For example, 'enumerator' is built in. If you require it, ruby # returns false as if it were already loaded; however, there is no # file to find on disk. We've pre-built a list of these, and we @@ -175,19 +181,27 @@ def now Process.clock_gettime(Process::CLOCK_MONOTONIC).to_i end if DLEXT2 - def search_index(f) - try_index(f + DOT_RB) || try_index(f + DLEXT) || try_index(f + DLEXT2) || try_index(f) + def search_index(f, try_extensions: true) + if try_extensions + try_index(f + DOT_RB) || try_index(f + DLEXT) || try_index(f + DLEXT2) || try_index(f) + else + try_index(f) + end end def maybe_append_extension(f) try_ext(f + DOT_RB) || try_ext(f + DLEXT) || try_ext(f + DLEXT2) || f end else - def search_index(f) - try_index(f + DOT_RB) || try_index(f + DLEXT) || try_index(f) + def search_index(f, try_extensions: true) + if try_extensions + try_index(f + DOT_RB) || try_index(f + DLEXT) || try_index(f) + else + try_index(f) + end end def maybe_append_extension(f) try_ext(f + DOT_RB) || try_ext(f + DLEXT) || f end