Skip to content
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

Script classes are not regenerated project-wide after first import #72154

Closed
aaronfranke opened this issue Jan 27, 2023 · 7 comments · Fixed by #72445
Closed

Script classes are not regenerated project-wide after first import #72154

aaronfranke opened this issue Jan 27, 2023 · 7 comments · Fixed by #72445

Comments

@aaronfranke
Copy link
Member

Godot version

4.0.dev.d1e5903c67956707948b1de370b807e3aad395b7

System information

macOS 13.1

Issue description

Script classes are not regenerated project-wide after first import. See the reproduction steps below.

This is a huge problem for large games since a class may not have all of its dependencies ready by the time it comes to parsing the script, so it doesn't get registered on the first pass, and there are no other passes. The only solution is to manually open every single script and save it (potentially multiple times if there are long dependency chains).

The symptom is happening as of #70557, but the root cause was still present before that PR. If I revert that PR, open the reproduction project, and then instead of deleting the below file I empty out the _global_script_class* members, A and B do not regenerate (but they do if you open and save them). This has become a serious regression because the class list is no longer saved to version control, so you can end up in a situation where deleting .godot/ results in a broken project until you manually open and save every script (for every developer, every time they delete .godot/).

Steps to reproduce

  1. Download an open the below minimal reproduction project.
  2. Look at the generated .godot/global_script_class_cache.cfg file. Both A and B will be in there (good).
  3. Close Godot and delete this file.
  4. Open Godot again.
  5. Look at the lack of a .godot/global_script_class_cache.cfg file. It is not regenerated (bad).
  6. Open the a.gd script and save it.
  7. Look at the generated .godot/global_script_class_cache.cfg file. Only A will be in there, but B will not (bad).

Minimal reproduction project

GlobalClassMissing.zip

@KoBeWi
Copy link
Member

KoBeWi commented Jan 28, 2023

Sounds very similar to #70667

EDIT:
So there are 2 problems here:
1 The editor doesn't detect that global_script_class_cache.cfg is missing and doesn't rescan scripts.
2 If dependency of a script is fixed, the script isn't automatically updated (like in #70667)

The first issue is rather minor, as you can just delete .godot folder to trigger rescan, but not sure what to do with 2. 🤔

@khellste
Copy link

Just to chime in here, deleting the .godot folder doesn't fix the issue for me. It just regenerates the script class cache but many script entries are missing.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 29, 2023

Are you deleting the folder while the Godot is not running? You have to close the project, delete the folder and open. Godot will scan all files and should fill all class entries.
Although it might fail to do so if the scripts have errors 🤔

@khellste
Copy link

khellste commented Jan 29, 2023

I'm closing Godot first. Here are my repro steps:

  1. Open the project using Godot 4.0beta16. The .godot folder from a previous version is still there and everything works fine.
  2. Close Godot.
  3. Delete the .godot folder.
  4. Reopen the project with Godot 4.0beta16.
  5. .godot is regenerated but many scripts are missing from global_script_class_cache.cfg and the project won't run. If I do a diff of the old script cache and the new one, the new script cache is missing ~half of its entries.

@FireCatMagic
Copy link
Contributor

I had this same issue.
For me, it was my extensions of custom classes only.
The classes extended from built in classes would register fine.
#72226

@MikeSchulze
Copy link

I run into the same issue, it was need to open every class edit and save.
Specaly when you run github actions like CI (because i never checkin tmp folders like .godot) the project is broken.
Run Godot --headless --editor --quit does not help

@aaronfranke
Copy link
Member Author

I can confirm that this issue is fixed with a combination of #72444 and #72445.

Streq pushed a commit to Streq/godot that referenced this issue Feb 9, 2023
I have no idea why anyone would do this, but this fixes it.

Fixes godotengine#72154. Depends on godotengine#72444 being merged to function properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants