Skip to content

Commit 89c6e93

Browse files
committed
$LOAD_PATH.resolve_feature_path does not raise LoadError when feature isn't found
1 parent 01e0ce5 commit 89c6e93

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Compatibility:
8484
* `Fiber.current` and `Fiber#transfer` are available without `require 'fiber'` like in CRuby 3.1 (#2733, @eregon).
8585
* Add `freeze` keyword argument to `Marshal.load` (#2733, @andrykonchin).
8686
* Add `Integer.try_convert` (#2733, @moste00, @eregon).
87+
* Update `$LOAD_PATH.resolve_feature_path` to return `nil` instead of raising `LoadError` when feature isn't found (#2733, @andrykonchin).
8788

8889
Performance:
8990

spec/tags/language/predefined_tags.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ slow:The predefined global constant ARGV contains Strings encoded in locale Enco
66
slow:Global variable $0 is the path given as the main script and the same as __FILE__
77
slow:Global variable $? is thread-local
88
slow:Global variable $0 actually sets the program name
9-
fails:$LOAD_PATH.resolve_feature_path return nil if feature cannot be found

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ def self.define_read_only_global(name, getter)
5555

5656
def $LOAD_PATH.resolve_feature_path(file_name)
5757
path = Truffle::Type.coerce_to_path(file_name)
58-
_status, path, ext = Truffle::FeatureLoader.find_feature_or_file(path, false)
59-
if Primitive.nil?(ext)
60-
raise Truffle::KernelOperations.load_error(file_name)
61-
else
62-
[ext, path]
63-
end
58+
status, path, ext = Truffle::FeatureLoader.find_feature_or_file(path, false)
59+
60+
return nil if status == :not_found
61+
[ext, path]
6462
end
6563

6664
# The runtime needs to access these values, so we want them to be set in the variable storage.

test/mri/excludes/TestRequire.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@
1717
exclude :test_require_nonascii_path_shift_jis, "needs investigation"
1818
exclude :test_relative_symlink_realpath, "bug17885 [ruby-core:104010]."
1919
exclude :test_load_into_module, "<[:b]> expected but was"
20-
exclude :test_resolve_feature_path_with_missing_feature, "LoadError: cannot load such file -- superkalifragilisticoespialidoso"

0 commit comments

Comments
 (0)