godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.57k stars 168 forks source link

F5 is not launching the game #462

Closed svprdga closed 8 months ago

svprdga commented 1 year ago

Godot version

4.0.1 Flathub

VS Code version

1.77.0

Godot Tools VS Code extension version

1.3.1

System information

Linux Mint

Issue description

After a while trying to connect Godot 4 with vscode, I finally got everything to work, except launching the game by pressing F5.

If in vscode I open the command palette, and choose "Godot tools: run workspace as Godot project" then the result is that the game launches correctly. But pressing the F5 key gives an error:

Failed to launch Godot instance: Error: Command failed: "/var/lib/flatpak/exports/bin/org.godotengine.Godot" --path "/path/to/my/project" --remote-debug 127.0.0.1 :6005

I use Godot 4 installed with Flatpak. The GDScript server works fine, and as I say I can launch the game if I choose that command from the palette.

Is there a way to make F5 launch that particular command and not what it's doing now?

Steps to reproduce

  1. Install Godot 4 from Flatpak
  2. Configure vscode as an external editor
  3. Try to launch the game by pressing F5
DaelonSuzuka commented 1 year ago

F5 should be using one of your existing debug configurations. Can you share the contents of your .vscode/launch.json file?

svprdga commented 1 year ago

Yes @DaelonSuzuka , here it is:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "GDScript Godot",
      "type": "godot",
      "request": "launch",
      "project": "${workspaceFolder}",
      "port": 6005,
      "address": "127.0.0.1",
      "launch_game_instance": true,
      "launch_scene": false
    }
  ]
}
Kregap commented 1 year ago

I am running from Windows, so it might be something else. That being said I had similar issues. Based on current stable documentation for command line value (uri) that is passed for you, for --remote-debug is wrong, it's missing tcp:// prefix. Godot Docs > Command line tutorial

--debug-server <uri> | Start the editor debug server (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007)

Try changing address line to: "address": "tcp://127.0.0.1", This fixed it for me.

svprdga commented 1 year ago

Hey @Kregap I tried your solution and it fixed the issue! Thank you for that.

I think that this project's README file should change the following line:

address": String that represents the IP address that the Godot remote debugger will connect to. Defaults to 127.0.0.1.

To include the tcp:// part you just told me. I don't know if this applies to all platforms, but I think it would be worth checking it out.

Tuckertcs commented 1 year ago

I am running from Windows, so it might be something else. That being said I had similar issues. Based on current stable documentation for command line value (uri) that is passed for you, for --remote-debug is wrong, it's missing tcp:// prefix. Godot Docs > Command line tutorial

--debug-server <uri> | Start the editor debug server (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007)

Try changing address line to: "address": "tcp://127.0.0.1", This fixed it for me.

I'm on Linux Mint (using VS Code with Godot 4.0.3), and this unfortunately did not fix my issue.

When I try to launch (F5 or the Run and Debug button), I get the following error popup:

Failed to launch Godot instance: Error: Command failed: "/home/username/dev/my-godot-game/project.godot" --path "/home/username/dev/my-godot-game" --remote-debug tcp://127.0.0.1:6007
/bin/sh: 1: /home/username/dev/my-godot-game/project.godot: Permission denied

This seems like it might be an issue with my system permissions or something (though the file has full read/write/execute permissions so idk), but I'll mention it here just in case others have a similar problem.

svprdga commented 1 year ago

@Tuckertcs I think that maybe you are setting your project path as your Godot installation path? If you go to the settings screen in VSCode, what do you have in Godot_Tools:Editor_path ?

Tuckertcs commented 1 year ago

@Tuckertcs I think that maybe you are setting your project path as your Godot installation path? If you go to the settings screen in VSCode, what do you have in Godot_Tools:Editor_path ?

I have the following settings in .vscode/settings.json:

"godot_tools.editor_path": "/home/username/dev/my-godot-game/project.godot",
"godot_tools.gdscript_lsp_server_port": 6005,
svprdga commented 1 year ago

@Tuckertcs your godot_tools.editor_path is pointing to a Godot project, not the executable itself, that's the issue. You need to set the path to your Godot executable, the file that you execute to run the engine.

Tuckertcs commented 1 year ago

@svprdga Ah okay, that makes sense. Thank you.

nkrisc commented 1 year ago

Had this issue, but resolved it. The problem I encountered was that even though I had editor_path set correctly in the extension settings, when I created a VS Code Workspace for my Godot project, the editor_path in the project_name.code-workspace file defaulted (?) to the project file, and the workspace setting was overriding the extension setting. I do see in the extension settings VS Code mentions that setting is modified in the Workspace settings, but it took me a bit to realize what the issue was.

DaelonSuzuka commented 8 months ago

@svprdga Have you tried this with the latest extension version (2.0.0)?

The debugger interface has been rewritten, so if your problem was in the extension, it should have been resolved.

It's also possible that this is some kind of flatpak issue, which I don't know anything about.

svprdga commented 8 months ago

@DaelonSuzuka In the end I was able to solve it, it was a configuration issue. But I will also try it in the new version 2.0.0 to see how it goes. I am closing this ticket since I consider the problem resolved.