-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugins & Autoloaded scripts breaks project if classes missing from global_script_class_cache.cfg #75388
Comments
In 4.0.2 I'm often running into this when changing branches with a lot of modifications. I open up Godot to a lot of errors of broken scripts. I go to git and see global_script_class_cache.cfg has changed, revert it, restart Godot and it comes right up. I'm surprised more people aren't running into classes being randomly dropped from global_script_class_cache.cfg. |
I've also run into this a ton, even on 4.0.3.stable. Thank you for reporting. I'm also surprised to see more people not having issues with this. |
This can also break gdscript plugins with custom class names and makes it very difficult to provide a smooth user experience when providing plugins with typed code. Custom classes are not recognized until they are in the script cache. Installing a new plugin means a user commenting out code until the script cache is populated, then those lines can be uncommented. In order to fix it, my plugin gdscript files cannot have class_names and I have to specify variables of those types as the built in type it extends. GDExtension class names are fine, so it's just a problem with the gdscript cache. |
Sigh... yes this has basically just completely broken my project. Going to start tracking changes on global_script_class_cache.cfg and reverting as needed. Until then, time to open all my files 😩 |
Hit this on 4.1.stable when my disk filled while editing scripts. Not only did that nuke the current script I was working on and emptied two scene files, but it triggered this same corruption for every class_name in my code and plugin code. Instead of opening every file and saving it to regenerate it, you can also just delete every file and restore it from your trash bin as that seems to trigger a mass "reindex". |
Anyone who takes a crack at fixing this issue likely ought to consider #92054 as well, which is similar to this issue in that you end up with scripts that are parsed before |
Many similar reports here: #76380 (comment) class_name is really not working as expected. |
Godot version
4.0, 4.0.1
System information
Windows 11/64, RTX 3070, Vulkan
Issue description
This will break our game and give hundreds of errors without our workarounds. It appears that autoloaded scripts are loaded before
global_script_class_cache.cfg
is populated, yet Godot only loads class names from that file. So, if a class isn't registered in the file, the autoload fails.Autoload ItemDB.gd, then close Godot, delete
global_script_class_cache.cfg
and reload. It will break with these errors:Stats and Util are two examples of the same problem. They can be tested independently. It is also an issue with any derivative classes. If ItemDB has an Item, which has a Stats, which is our set up, this also causes the issue.
It's not just a problem with an empty cache file. If someone on a team makes a change to these classes and saves the new class locally, those changes will not get to other team members via git, because Godot does not generate the new cache properly. We have some autoloaded base classes, so when this breaks, we get hundreds of error messages across many scripts.
Workarounds include:
global_script_class_cache.cfg
. Opening all, then saving all does not do it.global_script_class_cache.cfg
from another computerglobal_script_class_cache.cfg
in git. In spite of the name, it is NOT a cache. We ended up doing this to work around this bug.This bug has been present for a long while. We worked around it for a while, but finally discovered the exact circumstances today.
In my game, I have received this error message, though I don't get it in the MRP or while debugging. It may provide a clue:
The script cache can be added to .gitignore without adding the whole directory with this
Minimal reproduction project
test_gdscript_cache.zip
Bugsquad edit: used syntax highlighting for example gdscript code
The text was updated successfully, but these errors were encountered: