Gut icon indicating copy to clipboard operation
Gut copied to clipboard

error_if_not_all_classes_imported errors on startup

Open m-radzikowski opened this issue 5 months ago • 11 comments

Versions

  • Godot: v4.4.1.stable.official [49a5bc7b6]
  • GUT: 9.4.0
  • OS: Windows 11

The Bug

Errors on Godot startup:

Godot Engine v4.4.1.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
--- Debug adapter server started on port 6006 ---
--- GDScript language server started on port 6005 ---
[LSP] Connection Taken
  ERROR: res://addons/gut/gut_plugin.gd:7 - Invalid call. Nonexistent function 'error_if_not_all_classes_imported' in base 'GDScript'.
  ERROR: res://addons/gut/gut_plugin.gd:15 - Invalid call. Nonexistent function 'error_if_not_all_classes_imported' in base 'GDScript'.

With errors, GUT panel does not show.

Errors occur randomly. On my real project about 50% of time. On completely empty new project where the only thing I did was to install GUT, around 10% of the time.

When errors occur, Reload Current Project usually helps.

Steps To Reproduce

This is tricky. Theoretically "create new project, install GUT, Reload project many times".

However, I think the problem may be related to the VSCode connecting to the Language Server. Every time I got those errors, they were after [LSP] Connection Taken". I've added a log to gut_plugin.gd _init() and if log is after the LSP, there are no errors. I've decreased auto-reconnect colldown in godot-tools VSCode plugin to 100 ms and I'm getting errors almost every time.

After closing VSCode I cannot reproduce the error.

So the steps would be:

  1. Create new empty project
  2. Install GUT
  3. Open VSCode with godot-tools plugin
  4. In godot-tools, increase number of reconnect attempts and reduce the cooldown to 100 ms
  5. Restart VSCode to make sure settings are applied
  6. In Godot, click Reload Current Project
  • repeat sevaral times, you should get error most of the times

Related

#716 - unfortunatelly, applying the patch does not fix the error #723 #724

m-radzikowski avatar Jul 09 '25 18:07 m-radzikowski

I think you're onto something here. I am using VSCode with godot-tools and have similar issues.

I just tried reloading my Godot project few times right now with this result: VSCode connected:

  • Error seen

VSCode close:

  • No Error
  • No Error
  • No Error

VSCode connected:

  • Errors back

This seems more like an error with Godot or godot-tools than GUT, but GUT could probably handle it more gracefully.

jammons avatar Jul 09 '25 23:07 jammons

I've finally been able to replicate the issue with VSCode open and connected to the language server. I got the following a couple times out of 5 tries:

SCRIPT ERROR: Invalid call. Nonexistent function 'new' in base 'GDScript'.
          at: @static_initializer (res://addons/gut/utils.gd:167)
SCRIPT ERROR: Invalid call. Nonexistent function 'error_if_not_all_classes_imported' in base 'GDScript'.
          at: _init (res://addons/gut/gut_plugin.gd:7)
SCRIPT ERROR: Invalid call. Nonexistent function 'error_if_not_all_classes_imported' in base 'GDScript'.
          at: _version_conversion (res://addons/gut/gut_plugin.gd:15)

When VSCode was not running I was unable to replicate the issue with about 15 launches.

I was using the main branch of this project using MacOS 15.5 (24F74).

bitwes avatar Jul 10 '25 16:07 bitwes

Glad my suspiction was confirmed. Now I think some random initialization errors I have on my project's code have the same cause.

Anyway, I looked through Godot issues for LSP. No open issue seems relevant, but there is this with kinda similar behavior recently fixed and to land in 4.5: https://github.com/godotengine/godot/issues/108128

There is a chance this will fix it, but not necessarily.

m-radzikowski avatar Jul 10 '25 17:07 m-radzikowski

I've downloaded Godot 4.5.beta3 and it seems to solve the issue! 🎉

Startup logs show the plugin is always initialized before LSP is started ("GUT Plugin initialized" is added log in gut_plugin.gd#_init):

Godot Engine v4.5.beta3.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
--- Debug adapter server started on port 6006 ---
GUT Plugin initialized
Add Autoload
--- GDScript language server started on port 6005 ---
[LSP] Connection Taken

m-radzikowski avatar Jul 10 '25 17:07 m-radzikowski

This also happens in Godot 4.4 on osx. I also use VSCode and Godot. Deleting and re-installing GUT fixes the issue temporarily. I will try 4.5 beta 3 :)

Godot Engine v4.4.1.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors. ERROR: res://addons/gut/utils.gd:160 - Invalid call. Nonexistent function 'new' in base 'GDScript'. ERROR: res://addons/gut/gut_plugin.gd:7 - Invalid call. Nonexistent function 'error_if_not_all_classes_imported' in base 'GDScript'. ERROR: res://addons/gut/gut_plugin.gd:15 - Invalid call. Nonexistent function 'error_if_not_all_classes_imported' in base 'GDScript'.

Good catch on the VSCode errors: I also get- Couldn't connect to the GDScript language server at 127.0.0.1:6008. Is the Godot editor or language server running?

brookesy2 avatar Jul 17 '25 13:07 brookesy2

FYI, if you run tests through VSCode instead of Godot then you can mostly ignore this issue: https://github.com/bitwes/gut-extension. This is how I work 90% of the time.

I've done more testing/fix attempts and I've not been able to fix it yet, but I have learned a few things.

  • As stated somewhere, I only see the error when:
    • VSCode is open and connected.
    • Godot is closed
    • Godot is opened and VSCode reconnects upon opening
    • The error, when it occurs, always happens after "[LSP] Connection Taken" appears in the log.
    • After adding output to _init and _enter_tree in gut_plugin.gd:
      • You never see the output after "[LSP] Connection Taken" when everything works.
      • When the error does occur the output shows that the class trying to call error_if_not_all_classes_imported is a valid class and does have the method.

I'm convinced this is caused by Godot/godot-tools and is the issue mentioned earlier: godotengine/godot#108128. I'll be leaving this open until 4.5 is out and everyone is happy with it.

Workarounds

Don't run tests through the editor

Use https://github.com/bitwes/gut-extension to run tests through VSCode. That way, when the error occurs you don't have to care.

Do run tests through the editor

Do not launch Godot while VSCode is trying to establish/reestablish an LSP connection. If you close the editor while VSCode has an LSP connection, you should wait for it to timeout before relaunching the editor.

But what if I do close the editor while VSCode has an LSP connection and then I relaunch Godot and I encounter the error? Do any of the following:

  • Close VSCode and the editor (order does not matter). Relaunch the editor then relaunch VSCode.
  • Close the editor and relaunch...repeat until the error does not happen (should be twice at most).

bitwes avatar Jul 18 '25 16:07 bitwes

I've been implementing a lot of features for Godot 4.5 and I haven't seen this. I'm going to mark this as "next release" even though nothing has changed on the GUT side. The next release will require Godot 4.5.

bitwes avatar Aug 19 '25 22:08 bitwes

I installed GUT 9.5.0 through the AssetLib in Godot 4.5 stable on Linux, and I'm getting an error that looks very similar, though not exactly the same. Does this look like the same root cause?

Godot Engine v4.5.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
--- Debug adapter server started on port 6006 ---
--- GDScript language server started on port 6005 ---
[LSP] Connection Taken
  ERROR: res://addons/gut/utils.gd:186 - Invalid call. Nonexistent function 'new' in base 'GDScript'.

I'm using VSCodium rather than VSCode. Unlike the earlier comments, this seems to happen consistently, rather than intermittent and fixable by restarting the Godot editor.

Edit: After deleting and reinstalling GUT, the errors seems to have gone away. If everyone else's GUT is stable with 4.5, disregard this comment.

superlou avatar Sep 17 '25 23:09 superlou

I'm seeing this issue on Windows 11 using

  • Godot v4.5.1 stable
  • GUT Version: 9.5.0
  • VS Code 1.105.1

When I run the VS Code command > Gut: Run All or Gut: Run Current Script I see a the same error that @m-radzikowski sees. I can fix this error if I run the following command from PowerShell.

&"c:\PATH_TO_GODOT_EXE\Godot_v4.5.1-stable_win64.exe" --path $PWD addons\gut\gut_cmdln.gd -gdir=res://test/unit -gexit

If I were to remove the -gdir flag or use -gselect="test_foo.gd", my game starts up and I get an error about _read() from my global game_manager.gd script. I also see the same behavior if I use the VS Code command > Gut: Run Current Script (debugger)

ERROR: Node not found: "/root/SceneManager" (absolute path attempted from "/root/GameManager").
   at: get_node (scene/main/node.cpp:1904)
   GDScript backtrace (most recent call first):
       [0] _ready (res://Scripts/game_manager.gd:35)
SCRIPT ERROR: Cannot call method 'connect' on a null value.
   at: _ready (res://Scripts/game_manager.gd:38)
   GDScript backtrace (most recent call first):
       [0] _ready (res://Scripts/game_manager.gd:38)

Using the GUT UI in Godot when I click any of the Run options in Gut ie: (Run All, test_file, test_function_in_file) I get the same error above. I was able to to get the test to run when going into the GUT Run Mode and switching Run Mode from In Editor to Externally - NonBlocking However when I scroll up pass the test output I see the same error message output above.

Is there a setting I need to set to ignore my Global Script or Startup Script?

Here is my Gut settings:

{
 "background_color": "262626ff",
 "compact_mode": false,
 "configured_dirs": [
  "res://test/unit"
 ],
 "dirs": [
  "res://test/unit"
 ],
 "disable_colors": false,
 "double_strategy": 1,
 "failure_error_types": [
  "engine",
  "push_error",
  "gut"
 ],
 "font_color": "ccccccff",
 "font_name": "CourierPrime",
 "font_size": 16.0,
 "gut_on_top": true,
 "hide_orphans": false,
 "ignore_pause": true,
 "include_subdirs": true,
 "junit_xml_file": "",
 "junit_xml_timestamp": false,
 "log_level": 2.0,
 "no_error_tracking": false,
 "opacity": 100.0,
 "paint_after": 0.1,
 "post_run_script": "",
 "pre_run_script": "",
 "prefix": "test_",
 "should_exit": false,
 "should_exit_on_success": false,
 "should_maximize": true,
 "suffix": ".gd",
 "wait_log_delay": 0.5
}

NickSpaghetti avatar Nov 11 '25 01:11 NickSpaghetti

For the error_if_not_all_classes_imported error, you can try:

&"c:\PATH_TO_GODOT_EXE\Godot_v4.5.1-stable_win64.exe"  --import --headless

If you are also seeing this right after the LSP messages though, I suspect there might still be an issue with the LSP integration. What happens if you do not have Godot connected and you Run-Script or Run-All?

As for the Autoload, there is no way to disable an autoload when running tests. GUT used to load Autoloads (I remember doing it, but I can't find it anymore), but I'm pretty sure this is all done by the engine now. It sounds like you would have to change your autoload to be able to exist when tests are being run. It's hard to say what would have to change without knowing more about the code. I can help you through that if you open a separate issue.

bitwes avatar Nov 11 '25 17:11 bitwes

For some reason I cannot get the error_if_not_all_classes_imported error to appear in vscode now. It now only shows up in Godot when the run mode is set to In Editor.

When I run Run-Script or Run-All in vs code without Godot connected (By not connected if you mean godot IDE is not open) I get the errors from my Autoload script. I can open up another issue about Auto load errors.

NickSpaghetti avatar Nov 11 '25 21:11 NickSpaghetti