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

Class names suddenly seen as invalid #83561

Open
RaiHormo opened this issue Oct 18, 2023 · 8 comments
Open

Class names suddenly seen as invalid #83561

RaiHormo opened this issue Oct 18, 2023 · 8 comments

Comments

@RaiHormo
Copy link

RaiHormo commented Oct 18, 2023

Godot version

4.1.1 stable

System information

Godot v4.1.1.stable - Windows 10.0.22635 - Vulkan (Forward+) - integrated AMD Radeon(TM) Graphics (Advanced Micro Devices, Inc.; 31.0.22013.1002) - AMD Ryzen 7 7735U with Radeon Graphics (16 Threads)

Issue description

Suddenly all custom class names in my project (declared using class_name in scripts) produce this error:
Parser Error: Could not parse global class "(the name of the class)" from "res://(path to the script the class comes from)". and prevent the game from running.

This is fixed by going to the script, erasing one letter from the class name, typing it again and saving, but I would have to do that for every single one, which doesn't sound like a fun way to spend my day.

Steps to reproduce

I am unable to reproduce this. Before it happened, I was trying to export my game before I noticed these errors but I'm not sure what caused it. I reverted to an older version that wasn't affected and retraced my steps, but I couldn't reproduce it.
An attempt to reproduce it is happening though.

Minimal reproduction project

Production edit: 83561.zip

@AThousandShips
Copy link
Member

Can you please see if you have this happen on a more recent version like 4.1.2? Unfortunately there's little we can do for one off errors that can't be repeated

@RaiHormo
Copy link
Author

Can you please see if you have this happen on a more recent version like 4.1.2? Unfortunately there's little we can do for one off errors that can't be repeated

Updating to 4.1.2 does not fix the issue in the project affected by it

@AThousandShips
Copy link
Member

If you are able to figure out the steps to cause this, please provide them, or as a minimal reproduction project:

  • A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the .godot folder in the archive (but keep project.godot).
  • Drag and drop a ZIP archive to upload it. Do not select another field until the project is done uploading.
  • Note for C# users: If your issue is not Mono-specific, please upload a minimal reproduction project written in GDScript or VisualScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a Mono setup available.

@kb173
Copy link

kb173 commented Oct 24, 2023

I have the same issue right now, it started after removing the .godot folder and re-importing everything. The same fix described here works for me. I'm on v4.1.2.stable.arch_linux. No change in project.godot.

As far as I can tell, .godot/global_script_class_cache.cfg is not being generated properly. It only contains classes where I have done the fix described above (retyping the class_name in order to trigger Godot to register it).

I was able to manually replace .godot/global_script_class_cache.cfg with the old version (from the deleted .godot) and that fixed the issue.

@dpalais
Copy link
Contributor

dpalais commented Nov 27, 2023

Possibly related #83187

In my experience, .godot/global_script_class_cache.cfg often fails to update classes when a change is made outside of the editor. This happens to me quite frequently because I work on the same project on two computers, using Git to update the project files (but not global_script_class_cache.cfg because it is not tracked).

It seems I can add a class without difficulty. But a removed classes on one computer is never (or at least not usually) removed from global_script_class_cache.cfg on my other computer. Changing a class in some other way also won't update and leads to errors that never resolve without deleting the .godot directory. So... since updating to Godot 4, I've found it necessary to delete the .godot directory EVERY time I make any class change other than a simple addition

@derkork
Copy link

derkork commented Mar 22, 2024

I have a reported case of this in a mixed C#/GDScript project. Most edits take place in an external editor so this seems to be related to the issue with global_script_class_cache.cfg similar to how it is described in #83187 (comment) . It is really difficult to reproduce but happens consistently once or twice a day.

@adamscott
Copy link
Member

adamscott commented Jun 8, 2024

From what I experienced, this issue is due to the global class not being able to compile completely. What must be done is to make sure to:

  • comment class_name
  • fix every GDScript issues
  • uncomment class_name

The GDScript engine currently cannot refer to global classes that didn't compile at least once. It registers the class as global class only after it has successfully compiled.

Edit: I added the MRP into the issue description. 83561.zip

@m21-cerutti
Copy link

Maybe would be fixed with #92303 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants