How to handle "possible cyclic resource inclusion"?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rokato

Whenever I load the actual “game” scene of my project, I get multiple errors along the lines of:

ERROR: Another resource is loaded from path: res://Unit/UnitLogic.vs (possible cyclic resource inclusion) At: core\resource.cpp:78

It says it for a few visual scripts, gdscripts, and to one scene. This doesn’t seem to cause any issues when playing/debugging, but is there a way to clean these up? I’m not sure how to go about that.

:bust_in_silhouette: Reply From: Rafa_GBG

I had the same problem and in my case it was a problem with file name.
I was loading a resource with capital letter: “Squares.gd” but on my drive I had “squares.gd”. I’ve changed the filename and I don’t have this error anymore.

In the end of node’s inspector, there is a field named “Script”. Reset the old script, which is the upper case file name in your case, then re-assign the “new” script file with the lower case name. Then the problem should be fixed. If not, remove all the files under “\AppData\Roaming\Godot\projects[you project]” and reload your project.

meowyih | 2021-10-30 12:09

:bust_in_silhouette: Reply From: Larpon

I got these when loading the same resource from different Threads with both:
ResourceLoader.load_interactive(path)
and:
ResourceLoader.load(path)
Switching to loading the resource once and using Resource::duplicate(...) worked for me.

Maybe see This github issue

:bust_in_silhouette: Reply From: Poobslag

I encountered this error because I was loading the same resource concurrently in different threads. I resolved it by wrapping the “load” call with a mutex lock to ensure threads never loaded the same resource synchronously.

So instead of this:

func load_my_resource(var path:String) -> Resource):
    load(path)

Something like this:

var mutex = Mutex.new()
...

func load_my_resource(var path:String) -> Resource):
    load_mutex.lock()
    var result = load(path)
    load_mutex.unlock()
    return result