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

global_script_class_cache.cfg doesn't get properly generated if extension_list.cfg doesn't exist on first load #77478

Closed
BrianWiz opened this issue May 25, 2023 · 7 comments · Fixed by #93972

Comments

@BrianWiz
Copy link

BrianWiz commented May 25, 2023

Godot version

Tested with 4.0, 4.0.1, 4.0.2 and 4.0.3 Mono editions

System information

Tested on several Windows PCs and a Mac

Issue description

When the .godot folder doesn't exist and you have a gdextension in your project, the first launch causes a crash and causes global_script_class_cache.cfg to not generate correctly, breaking all gdscripts until you force the class_name on every script to re-register in the cache. (by commenting class_name out, save, uncomment, save, on every gd script).

Suggested workaround if you're working with git
Allow ./godot/extension_list.cfg in your .gitignore.

Steps to reproduce

  • Ensure .godot folder doesn't exist
  • Ensure your project has at least one gdextension
  • Ensure your project has at least one script with a global class name

Minimal reproduction project

This can be reproduced with a modified demo from godot-cpp, here is one compiled for Windows x64.
minimal_repro.zip

The project is inside the demo directory. I have included a script which contains a class_name named script_with_class_name.gd

  • The first launch should crash
  • Look at the .godot folder, no global_script_class_cache.cfg exists
  • Launch again, it shouldn't crash this time.
  • Look at the .godot folder again, global_script_class_cache.cfg exists now, but it does not have the class name in there.
@saletrak
Copy link

It happens to me also on Godot_v4.0.3-stable_macos.universal

@m21-cerutti
Copy link

m21-cerutti commented Feb 13, 2024

Tips from bitwes/Gut#520 (comment)
Use a first command to generate it wth more than 50 frames, like

godot --project . --headless --quit-after 200 -e 2>/dev/null
godot --headless ...

Don't fix the initial issue but can make a workaround

@Hilderin
Copy link
Contributor

Hilderin commented Jul 5, 2024

I tested the MRP with a build from master now that #92303 is merge. Godot does not crash on editor start if the .godot folder is missing and the global_script_class_cache.cfg is now correctly regenerated.

The only error I get is this one and I need to restart the editor to fix it:
image

It comes from the fact that if extension_list.cfg is missing, GDExtensions are loaded after the GDScriptLanguage::init and globals are not updated after GDExtensions are loaded. I'll try to create a PR to fix that also.

@akien-mga
Copy link
Member

Yeah this error sounds related to #53163, which was closed as presumably fixed but I never confirmed it myself. I always thought restarting the editor once when loading a project with a GDExtension was still the "normal" workflow, like for plugins.

@Hilderin
Copy link
Contributor

Hilderin commented Jul 5, 2024

Indeed, restarting the editor seems the preferred workflow. After a bit of investigation, it does not sound a good idea to modify that behavior.

@akien-mga
Copy link
Member

Well it's the preferred workflow due to bugs - ideally we should be able to resolve all imports and dependencies thereof on the first edit of a project, so that it works out of the box.

@Hilderin
Copy link
Contributor

Hilderin commented Jul 5, 2024

I totally agree with you, the process should be a lot smoother. I did some modifications locally to make it work but I'm really not sure it will cover all possibilities. Maybe later I'll create a PR just to have some feedbacks, who knowns!

@KoBeWi KoBeWi removed this from the 4.3 milestone Aug 3, 2024
@akien-mga akien-mga added this to the 4.4 milestone Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants