Project

General

Profile

Feature #19849

Updated by mame (Yusuke Endoh) about 1 year ago

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

 Example.new 
 ``` 

 and an autoload to define the `Example` constant, 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:4:in 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