Actions
Feature #19849
openRequiring file with autoload results in confusing error if file doesn't exist
Status:
Open
Assignee:
-
Target version:
-
Description
Given the following file that calls the Example
constant:
# example.rb
require_relative 'autoload_example.rb'
Example.new
and an autoload to define the Example
constant, with an unknown path:
# autoload_example.rb
autoload "Example", "path_unknown"
Running ruby example.rb
results in the following error:
<internal:~/.rubies/ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- path_unknown (LoadError)
from <internal:~/.rubies/ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from example.rb:4:in `<main>'
The error is somewhat confusing as it doesn't show the location of the autoload
which caused the error.
This can be especially confusing if the autoload is called somewhere deep in a gem.
Actions
Like0
Like0Like0Like0Like0Like0