Importing a class in singleton does not work in CI

Godot Version

4.2.1

Question

Hello.

This is a reduced version of my setup:

/tests/debug.gd

class_name DebugTool
extends Node


static func print(x: Variant) -> void:
	if OS.is_debug_build():
		print(x)

/global/network.gd

This is loaded as singleton.

extends Node

#[...]

# this get called on the server and clients
func _peer_connected(peer_id: int) -> void:
	DebugTool.print("Peer connected with id: " + str(peer_id))
#[...]

This works fine on my desktop.
However, if I build my project on CI I get this error:

[...]
SCRIPT ERROR: Parse Error: Identifier "DebugTool" not declared in the current scope.
          at: GDScript::reload (res://global/network.gd:18)
[...]

Is there something wrong with my script?
Is this a bug?
If this is a bug, has it been reported?

Is the singleton stuff called by the _ready() function? That could be a potential culprit.

I am not sure, what you mean.
The /global/network.gd has a _ready-function.
Here is how it looks like:

func _ready() -> void:
	multiplayer.connected_to_server.connect(_connected_to_server)
	multiplayer.connection_failed.connect(_connection_failed)
	multiplayer.peer_connected.connect(_peer_connected)
	multiplayer.peer_disconnected.connect(_peer_disconnected)
	multiplayer.server_disconnected.connect(_server_disconnected)

I reduced everything to a minimal project:

Here is an example output of the ci pipeline:

If you comment out this line (or skip all the 5 lines in the _ready() function), does the error message disappear?

It does not help, but I think I could reduce the problem more and I think it is a bug.
I will create a bugreport and link it here.

The problem is that the file .godot/global_script_class_cache.cfg not generated at first and that is somehow a problem.

There is already an issue open:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.