Skip to content

Commit 8f5d1fc

Browse files
committed
[GR-18163] Update patch feature finding to prefer the longest matching load path
PullRequest: truffleruby/3204
2 parents 6d7998f + f27de44 commit 8f5d1fc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Bug fixes:
1414
* Fix `Integer#{<<,>>}` with RHS bignum and long (@eregon).
1515
* Fix a resource leak from allocators defined in C extensions (@aardvark179).
1616
* `SIGINT`/`Interrupt`/`Ctrl+C` now shows the backtrace and exits as signaled, like CRuby (@eregon).
17+
* Update patch feature finding to prefer the longest matching load path (#2605, @bjfish).
1718

1819
Compatibility:
1920

src/main/ruby/truffleruby/core/truffle/feature_loader.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ def self.provide_feature(feature)
219219
end
220220

221221
def self.relative_feature(expanded_path)
222-
load_path_entry = get_expanded_load_path.find do |load_dir|
222+
load_path_entries = get_expanded_load_path.select do |load_dir|
223223
expanded_path.start_with?(load_dir) and expanded_path[load_dir.size] == '/'
224224
end
225-
if load_path_entry
225+
if !load_path_entries.empty?
226+
load_path_entry = load_path_entries.max_by(&:length)
226227
before_dot_rb = expanded_path.end_with?('.rb') ? -4 : -1
227228
expanded_path[load_path_entry.size+1..before_dot_rb]
228229
else

0 commit comments

Comments
 (0)