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

Using an external code editor prevents Godot from reloading tool and editor scripts #17044

Closed
RabbitB opened this issue Feb 26, 2018 · 8 comments

Comments

@RabbitB
Copy link

RabbitB commented Feb 26, 2018

Godot version:
Godot 3.0.1 Stable win64

OS/device including version:
Windows 10 Pro x64

Issue description:
If you use an external code editor (in this case VS Code; I haven't tried other editors) to edit tool or editor scripts, the in-engine editor will update properly to display the changes you made to the script in the external editor, but Godot is silently failing to actually reload the scripts.

The effect is that you modify a script, test something that relies on that script, and find that your changes are not reflected on execution.

Because it's relevant, this is how I have VS Code setup:

Use External Editor: √
Exec Path: C:/Program Files/Microsoft VS Code/code.exe
Exec Flags: {project} --goto {file}:{line}:{col}

Steps to reproduce:

• Make sure Use External Editor is off
• Create a simple tool GDScript

tool
extends Node2D

func _ready():
    print("Visible Output Text")

• Create a simple scene that consists of a single Node2D with the previously created script attached.
• Save and close the scene, then reopen and read what's printed to the output window (will be "Visible Output Text")
• Edit the script so that it prints "Different Text" and save.
• Close and reopen the scene and read what's printed to the output window again (should be "Different Text")
• Now repeat this process, but first enable Use External Editor

From experimenting, it looks that as long as Use External Editor is active, Godot fails to reload the scripts, even if you close the external editor. The only way to make it reload the scripts is to close Godot entirely, and relaunch.

@neikeq
Copy link
Contributor

neikeq commented Feb 26, 2018

This is a duplicate of #10946, although this issue has some useful detailed information.

Just to be sure, do you see the error ERROR: set_path: Another resource is loaded from path on script reload when running Godot the terminal?

If not, is any other error printed to the terminal?

@RabbitB
Copy link
Author

RabbitB commented Feb 26, 2018

There is no error printed to the terminal. The only time I see an error, is if I close Godot before closing the external editor. Then the terminal holds until the external editor closes.

These are the two errors I get in that instance:

WARNING: ObjectDB::cleanup: ObjectDB Instances still exist! At: core\object.cpp:1989
ERROR: ResourceCache::clear: Resources Still in use at Exit! At: core\resource.cpp:418

@T4g1
Copy link

T4g1 commented Aug 9, 2018

I have the same problem with an external editor both on platform x11 and windows with latest master (a71a5fc). Also, console gives the following output:

ERROR: set_path: Another resource is loaded from path: res://Level/Level.gd (possible cyclic resource inclusion)
   At: core/resource.cpp:78.

@carlmartus
Copy link

When I save from an external editor, I get two red lines in the Output window:

 core/resource.cpp:79 - Condition ' exists ' is true.
 modules/gdscript/gdscript.cpp:557 - Condition ' !p_keep_state && has_instances ' is true. returned: ERR_ALREADY_IN_USE

The tool script is not updated after this. However, if I make any change in the script from the internal code editor. The script reloads successfully.

Version: v3.1.stable.official
OS: Debian testing

@koodikulma-fi
Copy link

koodikulma-fi commented Jul 10, 2019

Godot 3.1.1, Windows 10
I also get the Another resource is loaded from path ... (possible cyclic resource inclusion) error when creating a GDScript programmatically and resaving it over the old file. The error comes when opening a scene that references the script (on the root), but only if it had been in the editor script list previously but is not anymore. The problem is actually worse, when the old script is still in the editor's script list - in that case, I don't get any error, but the scene is actually referencing the old script. It will only update (and the error appear), when I close the script from the editor's script list, and re-open the scene.

Also get sometimes that core/resource.cpp:79 - Condition ' exists ' is true.

... Also tried removing the script from disk for a couple of frames and asking EditorFileSystem to scan and update_path as well as script.reload() but couldn't get it working. (The scanning seems to happen after a timeout, so maybe should wait for longer.) ... Maybe if there was a command to "force refresh" or "unload" a script, it could work.. ? (Thought update_path would do that.)

Edit:
This applies partly to scenes, too: When saving over an existing scene, and then opening it up in the editor, the node structure is updated, but (scripts and) Animations are not. If you close Godot and reopen, they are updated (the .tscn file has the correct info). --> I suppose, a general method to "refresh/release" a resource / script / scene from editor's memory would do the trick (for my cases, anyway).

Edit 2:
Doing the above (= overriding a scene by script, and then loading it up - either in a new tab or within the current tree), will also sometimes "mix" or "shuffle" resources. For example, an export resource variable that was a script extending Resource, might become a RectangleShape2D from a collider (and the collider shape might be missing from where it's supposed to be). It seems that when running the scene (F6), things will actually work correctly (so it's the editor side resources that needs refreshing).

@akien-mga
Copy link
Member

Closing as duplicate of #10946 (as should have been done two years ago to avoid having redundant reports in two different threads).

If anything discussed here is missing in #10946, please link or copy it over :)

@luislodosm
Copy link

Godot 3.3.2
Visual Studio Code 1.56
macOS 11.4

Error when editing a script externally:

Captura de pantalla 2021-05-31 a las 0 38 56

@mehmet0zen
Copy link

Apparently the error occurs when you turn on the "Use External Editor" settings, I made a source code search and it seems like they didn't implement a code for this, so it will give the error of ERR_FAIL_MSG("Another resource is loaded from path '" + p_path + "' (possible cyclic resource inclusion).") if you checked this;
Screen Shot 2022-10-08 at 1 30 40 PM
But if you uncheck it, it won't be usefull for the snippets, what I would suggest is, make sure that you filled the Exec Path Correctly, and there is nothing in Exec Flags that would brake the code.

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.

9 participants