Project

General

Profile

Feature #19849

Updated by p8 (Petrik de Heus) 9 months ago

Given the following file that calls the `Example` constant: file: 
 ```ruby 
 # example.rb 
 require_relative 'autoload_example.rb' 

 Example.new 
 ``` 

 and an autoload to define the constant `Example` constant, is defined using autoload, with an unknown path: 
 ```ruby 
 # 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:1: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.

Back