When using an autoload scene that depends on pretty much any kind of imported resource you are more or less guaranteed to run into errors on the first run of the editor, or when running it through something like a CI build. These errors are usually along the lines of ERROR: Unable to open file: res://.godot/imported/[...], which seems to be due to the fact that autoloads are loaded before any resource importing has happened.
The errors in this particular MRP look like this:
ERROR: Unable to open file: res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex.
at: (scene\resources\compressed_texture.cpp:41)
Unable to open file: res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex.
ERROR: Failed loading resource: res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex. Make sure resources have been imported by opening the project in the editor at least once.
at: (core\io\resource_loader.cpp:278)
Failed loading resource: res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex. Make sure resources have been imported by opening the project in the editor at least once.
ERROR: Failed loading resource: res://icon.svg. Make sure resources have been imported by opening the project in the editor at least once.
at: (core\io\resource_loader.cpp:278)
Failed loading resource: res://icon.svg. Make sure resources have been imported by opening the project in the editor at least once.
Steps to reproduce
Delete any existing .godot folder (if loading the MRP again).
Load the MRP project from command-line.
Note the command-line (stderr) errors as shown in the issue description.
Note how my_autoload.gd fails with Cannot call method 'get_size' on a null value.
Load the MRP project from command-line again.
Note that there are no errors this time.
Note that some of these errors might not show up in the editor output log, as EditorLog hasn't been set up by the time they're emitted, so it's important to do this through command-line.
Also note that you can similarly reproduce these errors by running Godot with something like --headless --editor --quit, or even a command-line export, so long as you delete the .godot folder beforehand.
Tangentially related to #77037 and #89399, in the sense that it's about autoloads and editor load ordering, but shouldn't (in my opinion) be considered a duplicate of either.
Tested versions
Reproducible in: 4.3.dev [5d08c2631]
System information
Windows 11 (10.0.22631)
Issue description
When using an autoload scene that depends on pretty much any kind of imported resource you are more or less guaranteed to run into errors on the first run of the editor, or when running it through something like a CI build. These errors are usually along the lines of
ERROR: Unable to open file: res://.godot/imported/[...]
, which seems to be due to the fact that autoloads are loaded before any resource importing has happened.The errors in this particular MRP look like this:
Steps to reproduce
.godot
folder (if loading the MRP again).stderr
) errors as shown in the issue description.my_autoload.gd
fails withCannot call method 'get_size' on a null value
.Note that some of these errors might not show up in the editor output log, as
EditorLog
hasn't been set up by the time they're emitted, so it's important to do this through command-line.Also note that you can similarly reproduce these errors by running Godot with something like
--headless --editor --quit
, or even a command-line export, so long as you delete the.godot
folder beforehand.Minimal reproduction project (MRP)
imports-in-autoloads.zip