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

Relative preload syntax is not supported #649

Open
lonegamedev opened this issue Apr 19, 2024 · 10 comments
Open

Relative preload syntax is not supported #649

lonegamedev opened this issue Apr 19, 2024 · 10 comments
Labels
bug language server Issue is not originating from this extension, but from the LSP instead

Comments

@lonegamedev
Copy link

lonegamedev commented Apr 19, 2024

Godot version

v4.2.1.stable.arch_linux

VS Code version

1.88

Godot Tools VS Code extension version

2.0.0

System information

ArchLinux

Issue description

Relative preload path is not supported. It is recognized properly inside Godot editor.

const Messages = preload('./messages.gd')

Steps to reproduce

  1. Create gd script.
  2. Create another gd script, preload other script with relative path.
@DaelonSuzuka
Copy link
Collaborator

What's the actual problem you're having? "is not supported" could mean anything or nothing. Is there an error message, maybe?

@lonegamedev
Copy link
Author

It is marked as error, and when I hover I get:

Preload file "file://home/lgd/godot/multiplayer_playground/game_client/game/signaling/messages.gd" does not exist.gdscript(-1)

@DaelonSuzuka DaelonSuzuka added the language server Issue is not originating from this extension, but from the LSP instead label Apr 19, 2024
@DaelonSuzuka
Copy link
Collaborator

DaelonSuzuka commented Apr 19, 2024

Thank you. That's very important information that you should have included in your original post.

This is a problem with the Godot Language Server not correctly detecting file changes on disk, and not related to this extension.

Try restarting your Godot Editor.

@lonegamedev
Copy link
Author

lonegamedev commented Apr 19, 2024

Sadly restarting doesn't fix it for me.

ERROR: Attempt to open script 'file://home/lgd/godot/multiplayer_playground/game_client/game/signaling/signaling.gd' resulted in error 'File not found'.
                                              at: load_source_code (modules/gdscript/gdscript.cpp:1025)                                                                                             

@DaelonSuzuka
Copy link
Collaborator

Okay, that's a completely different type of error, caused by the actual game engine not finding the specified file. This is even less related to the extension than the first error.

I don't use preload() but it looks like you have a typo somewhere or you're specifying your relative path incorrectly.

@lonegamedev
Copy link
Author

Nah, the file is there. I'm observing something interesting.
When I open file through Code, I get all the errors with relative path, plus additional problem
I mentioned here: #650

However - if I enable Text Editor / External and open the file through Godot, it magically works.
Now if I open it from Code, it is broken again (it is treated as two seperate files).

/mnt/workbench/godot/multiplayer_playground/game_client/game/signaling/signaling.gd
/home/lgd/godot/multiplayer_playground/game_client/game/signaling/signaling.gd

I'm using symlink in my home directory - so perhaps this is what breaks it...

@DaelonSuzuka
Copy link
Collaborator

DaelonSuzuka commented Apr 19, 2024

I'm using symlink in my home directory - so perhaps this is what breaks it...

So you already know that you've done something wierd but you didn't investigate that first AND you didn't include that information in your initial report? That's a very interesting debugging strategy.

@lonegamedev
Copy link
Author

This is the first time I experienced that some LSP has problem with a symlink.

Anyway thanks for your help. Could be better if symlinks were properly resolved, but at least I can open file via Godot.

@atirut-w
Copy link

Could be better if symlinks were properly resolved

I've had problems with symlinks in VSCode in the past. Seems to be a VSCode problem.

@lonegamedev
Copy link
Author

lonegamedev commented Apr 20, 2024

I guess it depends on how you use them. I simply create a symlink to the whole project directory under home. This way I can have common location for mounting drives, but also convenience of organizing stuff in my home dir. Never had a single problem with this approach.

From what I see Godot is adamant on using abs paths. When I open a project launcher it shows paths via home.
Then, after I open a project, and Show in File Manager on any file it opens parent dir via abs path.

I don't know how this should be fixed, but my initial idea would be to resolve all paths to abs, before sending to LSP, since this is what Godot expects.

For example Node can do it via realpathSync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug language server Issue is not originating from this extension, but from the LSP instead
Projects
None yet
Development

No branches or pull requests

3 participants