godotengine/godot-vscode-plugin

Unable to launch debugger with Godot 4 (workaround included)

ooo-mmm opened this issue ยท 48 comments

Godot version

4.0 alpha 10

VS Code version

1.68.1

Godot Tools VS Code extension version

1.3.1

System information

Windows 11

Issue description

Unable to launch a debugger with Godot 4, connection with GDScript language server works fine.
Godot instance was already running.

My analysis says that an "&" is missing from suffix of exe

image

Steps to reproduce

Try opening debug session with default generated launch.json from VS code

I don't think they added Godot 4 support for this addon yet and a lot of things has changed between 3 and 4. Your best bet might be to wait for 4.0 to be released.

I don't think they added Godot 4 support for this addon yet and a lot of things has changed between 3 and 4. Your best bet might be to wait for 4.0 to be released.

Just to make sure I'm not doing something wrong, after all the setup, I also get Failed to launch Godot instance: Error: Command failed with Godot 4-beta1 (non-Mono) + VS Code,

So Godot 4.0 is still not support right?

In Godot 4.0 beta1, default LSP port is 6005, not 6008 (like 3.x).

LSP is for autocompletions, not debugging.

yoieh commented

The input flags has changed and now requires a port to launch with remote debugging.

By trying to launch it form a terminal you get this error:

PS> Godot_v4.0-beta2_win64.exe --path "....\Godot\PROJECT" --remote-debug 127.0.0.1:6008 
Invalid debug host address, it should be of the form <protocol>://<host/IP>:<port>.

I tested a none real protocole and it seems launches

PS> Godot_v4.0-beta2_win64.exe --path "....\Godot\PROJECT" --remote-debug any://127.0.0.1:6008
Godot Engine v4.0.beta2.official.f8745f2f7 - https://godotengine.org
Vulkan API 1.2.0 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 970
--------------------------------
...

Adding the same fake protocole to the address field in launch.json launches a debug window but workout working breakpoints.

image


Edit:

Chaning the protocol to tcp and prot to 6006 breakpoints stops the runtime but gives not feedback in vscode.

image

looks like 6006 is the defualt debug adapter port not 6008

image

I was able to adjust the launch.json and use the tcp port like you mentioned, and get the editor to launch, but I get some strange errors, and the debugger doesn't work still.

I don't expect things to work prior to Godot 4 launch, just interesting and thought I'd share the error.

Failed to launch Godot instance: Error: Command failed: "D:\Game Dev\Godot\Godot 4\Godot_v4.0-beta2_win64.exe" --path "D:\Game Dev\Games\Constellation-Cadence" --remote-debug tcp://127.0.0.1:6007 --breakpoints res://Levels/Conductor.gd:30,res://Levels/level.gd:27,res://Levels/level.gd:30,res://Levels/level.gd:33,res://Levels/level.gd:36,res://Levels/level.gd:37 ERROR: Remote Debugger: Unable to connect. Status: 1. at: connect_to_host (core/debugger/remote_debugger_peer.cpp:182) SCRIPT ERROR: Parse Error: Expected ":" after function declaration. at: GDScript::reload (res://Preload/Transitions/sceneTransition.gd:8) WARNING: ObjectDB instances leaked at exit (run with --verbose for details). at: cleanup (core/object/object.cpp:1956) ERROR: Resources still in use at exit (run with --verbose for details). at: clear (core/io/resource.cpp:473)

yoieh commented

@Zyjinn

failed: "D:\Game Dev\Godot\Godot 4\Godot_v4.0-beta2_win64.exe" --path "D:\Game Dev\Games\Constellation-Cadence" --remote-debug tcp://127.0.0.1:6007 --breakpoints

Check your remot debugging port really is 6007

Project -> Network -> Debug Adapter

I have not gotten brakeponts working ether but I got it to lunch.

@yoieh Oh, yeah I got the software to launch, just no breakpoints, which is hard to sell because if I'm going to use it as a primary editor, and I can't debug, that's a pretty big issue for me personally.

If you change the external editor, I don't think there's even a way to set breakpoints in the godot editor either, so you can't even use VSC for coding and godot for debugging super well, other than by kinda like, using VSC most times, and then just using Godot when you want to debug and not setting the external editor.

I'll play around with it, but mostly going to wait for debugging to come back for now, but thanks for the notice!

Hey guys!
I was able to get breakpoints working with this launch.json
First of all, obviously godot_tools.editor_path is set in settings.json
I'm not using tcp as advised above, but have added "debugServer": 6006 to the default config

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Godot",
      "type": "godot",
      "request": "launch",
      "project": "${workspaceFolder}",
      "port": 6006,
      "debugServer": 6006,
      "address": "127.0.0.1",
      "launch_game_instance": true,
      "launch_scene": false
    }
  ]
}

As for Godot options:
-- Debug Adapter - Sync Breakpoints is True
-- Debug - Remote Port is 6006
-- Deploy with Remote Debug is True as shown below

screenshot

You might have to launch your game in Godot Editor once (with at least one breakpoint set from VSCode) and then breakpoints should work in VSCode as well. Also, note that as of Beta 3, breakpoints set in VSCode can be disabled only from Godot Editor

Running on Godot 4 Beta 3 and Godot Tools 1.3.1

Thanks @Winprox , I can confirm that in Godot 4.0 Beta 4 I had to follow most one of your instructions before debugging GDScript worked -- except for setting Debug - Remote Port away from its default of 6007. I did have to launch the game in Godot Editor with breakpoints set in VSCode.

And I think you meant launch.json not config.json, and I think the only change you made was to add the debugServer entry.

So to summarize,

To get VSCode GDScript debugging working in Godot 4.0 Beta 4:

In VSCode

  1. In Settings, search for godot and set Godot_tools: Editor_path to the Godot executable
  2. If your workspace has no .vscode/launch.json file,
    • Open the Run and Debug sidebar, click create a launch.json file
    • Choose GDScript Godot Debug to create the file
  3. In launch.json:
    • Change "port" to 6006
    • Add on the next line: "debugServer": 6006

In Godot Editor

  1. Enable the Debug menu's Deploy with Remote Debug entry
  2. In Editor Settings, set Network/Debug Adapter/Remote Port to 6006
  3. In Editor Settings, set Network/Debug Adapter/Sync Breakpoints to On

Finally

  1. Add a breakpoint in VSCode.
  2. Run your project in Godot Editor, then stop it.

Now from VSCode you can Start Debugging, and it should run your code, and trip your breakpoint. Happy debugging!

PS: See next comment if you're using C# -- I don't know how to get that working :/

@michaelgundlach I've followed these instructions and @Winprox's multiple times to the letter but debugging from VSCode 1.73.0 still doesn't work on Godot v4.0.beta4.mono.official [e6751549c] with Godot Tools 1.3.1. Start Debugging results in Godot reporting [DAP] Connection Taken and if repeated will eventually result in Max client limits reached, but the program never starts. If Start Debugging is used while the program is running it shuts down and no debugging occurs. This is occurring in a project with mixed GDscript and C#.

On further inspection this error occurs on Start Debugging:

[error] The editor and client are working on different paths; the client is on 
"d:\gameDev\gd4proj\builder\pawn.cs", but the editor is on "D:/gameDev/gd4proj/builder": CodeExpectedError: 
The editor and client are working on different paths; 
the client is on "d:\gameDev\gd4proj\builder\pawn.cs", but the editor is on "D:/gameDev/gd4proj/builder"

This definitely seems related to C#.

Sorry @glimpsebeyond, I'm just using GDScript. I updated my comment to not disappoint C# users. If you figure it out ping me again and I'll update the comment again.

@michaelgundlach I tried it using the godot build without C# and a new gdscript only project and the behavior is mostly unchanged, though it did resolve that error I posted the program does not open.

@glimpsebeyond @michaelgundlach
Same for me - it resolves errors in vscode, but the debugger immediately quits.
Might be an issue with the Godot editor, or something needs to be changed in the editor settings.
s

Edit: No idea how I caused the "Max client limits reached" errors. The vscode debugger either starts and stops or kills it if already started from the Godot editor.

Edit: "Max client limits reached" errors seem to occur when changing launch.json while the Godot editor is connected.

@michaelgundlach I was also seeing the [DAP] Connection Taken error, although unlike the above users, I only see the error once, and get nothing from the debugger.

I even tried going into the scripts menu and closing any open scripts, and even going into the "scripts" menu under "debug" and selecting "debug with external editor" and it still shows the error [DAP} Connection Taken

I also tried messing around with the ports as well, trying different ones, as well as making sure the debugServer and port properties were not the same, and no luck.

Not sure what is still taking that port? I tried running a netstat, and only saw the listening ports from Godot looking at the ports specified for the debug server.

Let me know if anyone finds anything else regarding this, I would of course like to use Vscode whenever possible for debugging, but for now, it's understandable as it's beta afterall

I'm having a similar issue with respect to C# debugging. Looking in my VSCode terminal tab where the GodotTools is launching Godot's debug mode:

Running: /opt/Godot/Godot_v4.0-beta13_mono_linux_x86_64/Godot_v4.0-beta13_mono_linux.x86_64 --path /home/thoraxe/Documents/spacetrader/spacetrader-godot --remote-debug tcp://127.0.0.1:6007 --editor-pid 1313396 --position 960,572 res://Scenes/Main.tscn
ERROR: Couldn't find the given section "res://Scenes/CameraController.cs" and key "state", and no default was given.
   at: get_value (core/io/config_file.cpp:86)
ERROR: Condition "!breakpoint_list.find(breakpoint)" is true. Returning: Array()
   at: update_breakpoints (editor/debugger/debug_adapter/debug_adapter_protocol.cpp:799)

The file CameraController.cs is definitely in the stated place:

find | grep \.cs | grep Scenes
./Scenes/Main.cs
./Scenes/Camera3D.cs
./Scenes/CameraController.cs

Not sure if this warrants a separate issue.

Here's my launch config:

    {
      "name": "Launch",
      "type": "godot-mono",
      "request": "launch",
      "mode": "executable",
      "preLaunchTask": "build",
      "debugServer": 6006,
      "executable": "/opt/Godot/Godot_v4.0-beta13_mono_linux_x86_64/Godot_v4.0-beta13_mono_linux.x86_64",
      "executableArguments": [
        "--path",
        "${workspaceRoot}"
      ]
    },

Using the config specified in #389 (comment) does not make breakpoints work, but it doesn't produce the odd errors.

I am setting a breakpoint, launching the editor from vscode, running the project in the editor after launching the editor from vscode, stopping the project, and then running the project again from VSCode.

I'm on 4 Beta13.

same issue with GDScript @thoraxe

i followed the instruction that @michaelgundlach give earlier, works on Linux Mint, and have same error with @kkhhaann on WIndows 11

The "Max clients limit reached" error seems to happen after opening and closing the debug session 8 times. I assume the DAP server can only take 8 connections before it maxes out, and for some reason each time you try to debug from vscode it eats a new client. (I am using GDscript, so it doesn't seem to be exclusively C#)

Also this can even happen with the language server if you open and close vscode 8 times. It maxes out the connections. Though this is not really a problem anyone is likely to run into.

I'm also having the same issue, I can get the DAP connection but can't get breakpoints to work correctly. Or get it to run from VS code.

Hi, I implemented the DAP backend in Godot quite a long time ago, and haven't really looked at it lately to check if it's working properly. I'll have a look regarding some issues reported here.

One thing I've neglected to do was document how to configure Godot and text editors to use this protocol. I'll have a look and see if this could be added to Godot Docs. In the mean time, this comment and my GSOC report should have all the info you need to setup DAP through VSCode.

Wow, I think this is exactly the information I needed to finish the Godot 4 debugger support PR. Thank you for the links.

newjbl commented

Thanks @Winprox , I can confirm that in Godot 4.0 Beta 4 I had to follow most one of your instructions before debugging GDScript worked -- except for setting Debug - Remote Port away from its default of 6007. I did have to launch the game in Godot Editor with breakpoints set in VSCode.

And I think you meant launch.json not config.json, and I think the only change you made was to add the debugServer entry.

So to summarize,

To get VSCode GDScript debugging working in Godot 4.0 Beta 4:

In VSCode

  1. In Settings, search for godot and set Godot_tools: Editor_path to the Godot executable

  2. If your workspace has no .vscode/launch.json file,

    • Open the Run and Debug sidebar, click create a launch.json file
    • Choose GDScript Godot Debug to create the file
  3. In launch.json:

    • Change "port" to 6006
    • Add on the next line: "debugServer": 6006

In Godot Editor

  1. Enable the Debug menu's Deploy with Remote Debug entry
  2. In Editor Settings, set Network/Debug Adapter/Remote Port to 6006
  3. In Editor Settings, set Network/Debug Adapter/Sync Breakpoints to On

Finally

  1. Add a breakpoint in VSCode.
  2. Run your project in Godot Editor, then stop it.

Now from VSCode you can Start Debugging, and it should run your code, and trip your breakpoint. Happy debugging!

PS: See next comment if you're using C# -- I don't know how to get that working :/

yes, by this way the debugging can work....
it means you should add the breakpoints both on VSCODE and Godot editor, and press F5 to start debug in VSCODE, then both VSCODE and Godot will stop at the breakpoint.

So, i think the issue is: godot-tools can't Synchronize the breakpoints from VSCODE to Godot 4.0
the godot-tools don't release any new version, so i think it probably that the bug is from Godot 4.0 .....

Thanks @Winprox , I can confirm that in Godot 4.0 Beta 4 I had to follow most one of your instructions before debugging GDScript worked -- except for setting Debug - Remote Port away from its default of 6007. I did have to launch the game in Godot Editor with breakpoints set in VSCode.

And I think you meant launch.json not config.json, and I think the only change you made was to add the debugServer entry.

So to summarize,

To get VSCode GDScript debugging working in Godot 4.0 Beta 4:

In VSCode

  1. In Settings, search for godot and set Godot_tools: Editor_path to the Godot executable

  2. If your workspace has no .vscode/launch.json file,

    • Open the Run and Debug sidebar, click create a launch.json file
    • Choose GDScript Godot Debug to create the file
  3. In launch.json:

    • Change "port" to 6006
    • Add on the next line: "debugServer": 6006

In Godot Editor

  1. Enable the Debug menu's Deploy with Remote Debug entry
  2. In Editor Settings, set Network/Debug Adapter/Remote Port to 6006
  3. In Editor Settings, set Network/Debug Adapter/Sync Breakpoints to On

Finally

  1. Add a breakpoint in VSCode.
  2. Run your project in Godot Editor, then stop it.

Now from VSCode you can Start Debugging, and it should run your code, and trip your breakpoint. Happy debugging!

PS: See next comment if you're using C# -- I don't know how to get that working :/

I had one final change I needed to do on top of what was listed above to get breakpoints working for me:
in the launch.json set the address to "address":"local:127.0.0.1",

I noticed that in the link provided by @rsubtil the address had the local: prefix so gave it a shot and everything started working.
hopefully that helps some people still struggling with this.

Edit: well...nevermind...it worked ONCE for me...then stopped picking up breakpoints again...sigh...

Edit: well...nevermind...it worked ONCE for me...then stopped picking up breakpoints again...sigh...

There are still some issues remaining, but in your case I think godotengine/godot#75849 may already fix this. Can you test with Godot 4.0.3 RC 2 (https://godotengine.org/article/release-candidate-godot-4-0-3-rc-2/) to check if that's the case?

Edit: well...nevermind...it worked ONCE for me...then stopped picking up breakpoints again...sigh...

There are still some issues remaining, but in your case I think godotengine/godot#75849 may already fix this. Can you test with Godot 4.0.3 RC 2 (https://godotengine.org/article/release-candidate-godot-4-0-3-rc-2/) to check if that's the case?

Thanks for the suggestion, it was worth a shot but I tried out 4.0.3 and I am still not able to get things to work.
It seems like there 2 states I can get it into that are ALMOST working:

With the "debugServer" set in launch.json:

  • It getd communication from godot into vscode to stop on breakpoints set in godot and allow stepping through code.
  • It does not seem to communicate the breakpoints set in VSCode to the launched program. Only Godot set breakpoints function.

With the "debugServer" setting NOT set in launch.json:

  • It will communicate the breakpoints set in VScode to godot so the program successfully stops on them.
  • It will not actually communicate back to VSCode to display when a breakpoint is reached and give control to step through or resume the code.
  • It also does not seem to link up with the open godot instance to display breakpoints there, or allow stopping / restarting / pausing the program from there.

So it seems that setting the debugServer setting stops in from communicating out from VScode. And not setting it stops it from communicating back into VSCode (or anywhere else) :/

Edit: Also just remembered. When using the "debug Server" setting, I also have to change the "project" from ${workspaceFolder} to the actual path using forward slashes.

Was able to get things working using the pull request version of the plugin here: Debugger Fixes for Godot 4.0 and just creating a package to install manually.

Looks like quite a bit about how communications are sent from godot so a lot of work is going into that pull request to get it all functioning and backwards compatible with Godot 3.

One thing I did not expect, is that if you have the godot editor open, you have to make sure the Godot Debug > Remote Port does NOT match the port you set in launch.json. I had thought the godot setting was just to point it to a remote server to send its debug data to, but it turns out godot is creating a server on that port, so if godot is already running it is taking up the port and does not let the plugin start one.
I did some playing around to see if the plugin could just connect to the server that godot is starting up instead, seems possible but I am not sure it is sending out all the same events or if it would be worth switching it over in the long run.

Hello! I am just +1 to the debugging with breakpoints in vscode for godot script, got stuck here myself. If yall figure out how to set it up consistently it would be super cool to push that out to the Godot4 setup docs! Currently the VSCode debugging instructions are mostly for c# or editing the engine it seems

Small update
I've submitted two patches to fix issues on the engine side, and now that Godot 4.1 was released, these two should be fixed:

painh commented

Hello

Is there any update on this?
I'm still running on f5 in vscode and I don't think I can use breakpoint in godot at the moment.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "GDScript Godot",
      "type": "godot",
      "request": "launch",
      "project": "${workspaceFolder}",
      "port": 6006,
      "debugServer": 6006,
      "address": "tcp://127.0.0.1",
      "launch_game_instance": true,
      "launch_scene": false
    }
  ]
}

godot 4.1.1 -> Editor -> Editor Settings -> Network -> Debug Adapter -> Report Port 6006

godot 4.1.1 -> Debug -> Deploy with Remote Debug On

Has anyone tried gdscript debugging by installing godot in steam version on windows?

Is there any update on this?

Still working on it.

Has anyone tried gdscript debugging by installing godot in steam version on windows?

That's not going to make any difference unless something is very wrong with your OS/environment.

Launch debugger with Godot 4

VSCode: VSCodium Version: 1.82.2
Date: 2023-09-14T18:27:11.315Z
OS: Linux x64 6.3.3-2-rt15-MANJARO
godot-tools: v1.3.1
Godot Version: 4.1.1-stable (gdscript)

Things that are working for me:

  • Breakpoints synced from vscode -> godot editor.
  • Profilers in Godot editor are live
  • stepping, pausing, starting, stopping in vscode debug interface.

Things that look like bad behaviors

  • debug console in vscode only updates with standard output messages
  • all other output (errors, warns, etc...) is updated in the vscode terminal that launched the debug process.

launch.json*

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "GDScript Godot",
            "type": "godot",
            "request": "launch",
            "project": "${workspaceFolder}/project",
            "port": 6006,
            "debugServer": 6006,
            "address": "127.0.0.1",
            "launch_game_instance": true,
            "launch_scene": false
        }
    ]
}

The only setting I changed in Godot Editor:

Editor>Editor Settings>Network>Debug Adaptor>"Sync Breakpoints""> On : True (tick the box)

*note: the debugServer and port number are derived from the Debug Adaptor port number. What ever is set there is what you want to type into your launch.json.

I hope this helps. It was extremely difficult to figure this out, so if you are a user having trouble hang in there.

Maintainers/Devs: It seems like the original issue is resolved. BUT there are no instructions anywhere on how to properly configure godot gdscript and vscode to work with this plugin. Again it was extremely difficult to figure out what levers to pull and buttons to push to get everything working. So I suggest we get the docs updated and/or update the defaults to something closer to what works. Let me know if I can help out in anyway. Thank you for all your work on this.

Maintainers/Devs: It seems like the original issue is resolved. BUT there are no instructions anywhere on how to properly configure godot gdscript and vscode to work with this plugin. Again it was extremely difficult to figure out what levers to pull and buttons to push to get everything working. So I suggest we get the docs updated and/or update the defaults to something closer to what works. Let me know if I can help out in anyway. Thank you for all your work on this.

I started a dedicated section in Godot's docs to document this from Godot's side.

Launch debugger with Godot 4

VSCode: VSCodium Version: 1.82.2 Date: 2023-09-14T18:27:11.315Z OS: Linux x64 6.3.3-2-rt15-MANJARO godot-tools: v1.3.1 Godot Version: 4.1.1-stable (gdscript)

Things that are working for me:

  • Breakpoints synced from vscode -> godot editor.
  • Profilers in Godot editor are live
  • stepping, pausing, starting, stopping in vscode debug interface.

Things that look like bad behaviors

  • debug console in vscode only updates with standard output messages
  • all other output (errors, warns, etc...) is updated in the vscode terminal that launched the debug process.

launch.json*

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "GDScript Godot",
            "type": "godot",
            "request": "launch",
            "project": "${workspaceFolder}/project",
            "port": 6006,
            "debugServer": 6006,
            "address": "127.0.0.1",
            "launch_game_instance": true,
            "launch_scene": false
        }
    ]
}

The only setting I changed in Godot Editor:

Editor>Editor Settings>Network>Debug Adaptor>"Sync Breakpoints""> On : True (tick the box)

*note: the debugServer and port number are derived from the Debug Adaptor port number. What ever is set there is what you want to type into your launch.json.

I hope this helps. It was extremely difficult to figure this out, so if you are a user having trouble hang in there.

Maintainers/Devs: It seems like the original issue is resolved. BUT there are no instructions anywhere on how to properly configure godot gdscript and vscode to work with this plugin. Again it was extremely difficult to figure out what levers to pull and buttons to push to get everything working. So I suggest we get the docs updated and/or update the defaults to something closer to what works. Let me know if I can help out in anyway. Thank you for all your work on this.

@loteque This was the perfect solution. Excellent job outlining the steps in detail. I was missing a couple pieces I couldn't find. I now have fully functional debugging with breakpoints, watches... all of it inside VSCode. You are a god among men for this. Kudos!!!

I spoke too soon. Apparently things are completely different in 4.1.2 because now breakpoints aren't being respected. I guess I'll go back to 4.1.1 until the Godot crew get their act together.

Hey y'all, I'm on Windows 10, Godot version 4.1.2-stable, VS:Code 1.84.2, and godot-tools 1.3.1.

My configuration in my launch.json looks like this:

{
    "name": "GDScript Godot",
    "type": "godot",
    "request": "launch",
    "project": "${workspaceFolder}",
    "port": 6007,
    "debugServer": 6006,
    "address": "127.0.0.1",
    "launch_game_instance": true,
    "launch_scene": false
}

Inside of Godot, I've enabled "Sync Breakpoints" in the DAP settings. When I run the debugger with at least one breakpoint set, or if I add/remove a breakpoint when the DAP session is running, I get the following error inside of the Godot output window: editor/debugger/debug_adapter/debug_adapter_protocol.cpp:800 - Condition "!breakpoint_list.find(breakpoint)" is true. Returning: Array(). It does look like this error persists if you have "Sync Breakpoints" as well.

I searched for this error in the issues and didn't find anything. Would be interested if anyone has had this error and has fixed it!

EDIT: I got breakpoints working shortly after posting this by disabling the external editor option. Previously, I was using VS:Code as my external editor, and after I disabled this, it appears that breakpoints are syncing back and forth between VS:C & the Godot editor, and the breakpoints are stopping with info inside of VS:C as well. The error I mentioned above still shows in the output when this happens though.

I believe I stumbled on a fix for my situation. I use VSCode as my editor and I have it set as my external editor. I'm able to get debugging in VSCode with functional breakpoints by doing the following.

In Godot editor:
Editor -> Editor Settings
Under Network -> Debug. Set Remote Port to 6007
Under Network -> Debug Adapter. Set Remote Port to 6008, Sync Breakpoints to On

In VSCode:
Edit the project's launch.json
Make changes to the port and debugServer values. Set the port value to what you used in Network->Debug in the Editor Settings. Set debugServer to the value you set in Network->Debug Adapter in the Editor Settings. Here's what mine looks like.

"configurations": [
    {
        "name": "Godot Debug",
	"type": "godot",
	"request": "launch",
	"project": "${workspaceFolder}",
	"port": 6007,
	"debugServer": 6008,
	"address": "127.0.0.1",
	"launch_game_instance": true,
	"launch_scene": false
    }
]

Hopefully this helps.

@renodubois can you provide a code sample where you can trigger such issue? While I haven't been able to replicate your issue yet, I am noticing some unreliable behavior on Windows, and it might be due to my recent fix regarding path separators, which I'm debugging now.

I believe I stumbled on a fix for my situation. I use VSCode as my editor and I have it set as my external editor. I'm able to get debugging in VSCode with functional breakpoints by doing the following.

In Godot editor: Editor -> Editor Settings Under Network -> Debug. Set Remote Port to 6007 Under Network -> Debug Adapter. Set Remote Port to 6008, Sync Breakpoints to On

In VSCode: Edit the project's launch.json Make changes to the port and debugServer values. Set the port value to what you used in Network->Debug in the Editor Settings. Set debugServer to the value you set in Network->Debug Adapter in the Editor Settings. Here's what mine looks like.

"configurations": [
    {
        "name": "Godot Debug",
	"type": "godot",
	"request": "launch",
	"project": "${workspaceFolder}",
	"port": 6007,
	"debugServer": 6008,
	"address": "127.0.0.1",
	"launch_game_instance": true,
	"launch_scene": false
    }
]

Hopefully this helps.

At least in Godot 4.2.1, port 6006 seems to be the default for the debug server. Therefore, using your configuration with this port and not changing any Editor settings also worked for me.

Here's the full .vscode/launch.json:

{
    "version": "0.2.0",
    // https://github.com/godotengine/godot-vscode-plugin/issues/389#issuecomment-1806992798
    "configurations": [
        {
            "name": "Godot Debug",
            "type": "godot",
            "request": "launch",
            "project": "${workspaceFolder}",
            "port": 6007,
            "debugServer": 6006, // 6006 is the default, at least in Godot 4.2.1
            "address": "127.0.0.1",
            "launch_game_instance": true,
            "launch_scene": false
        }
    ]
}

Shouldn't it be fixed already in 2.0 in master?

Shouldn't it be fixed already in 2.0 in master?

Yeah, the original issue is definitely fixed in master.

Hello, I'm adding my two cents here after searching how to connect VSCode to Godot :

  • The launch.json and settings.json are in the .vscode folder of your Godot project

  • If launch.json doesn't exist you can create it in that folder, VSCode will propose you to add a configuration

  • You need to specify the language server port in the settings.json, by default in my 4.2.1 it's 6005 but the default of the extension is 6008 :

    "godot_tools.gdscript_lsp_server_port": 6005

  • To manage debugging in VSCode you need to press F5 in VSCode (not launching from the Godot editor)

Same issue in 4.2.1

It was not working for me, then:

I noticed that I started the app with --remote-debug tcp://127.0.0.1:6006 it stops on break points. But it 'revives' some breakpoints that I had removed.
The breakpoint needs to be defined before execute, if i put the breakpoint after it shows ERROR: Condition "!breakpoint_list.find(breakpoint)" is true. Returning: Array()

After I have run with --remote-debug, if a close de process and start again it shows ERROR: Remote Debugger: Unable to connect. Status: 3..

I need to remove --remote-debug tpc://127.0... and run the startup command
"path-to-godot/godot.linuxbsd.editor.x86_64" --path "path-to-godot-project" -e and the breakpoints start to work again. It continues 'reviving' breakpoints.

After ran with --remote-debug tcp... even after restart my PC it don't need to use --remote-debug anymore to it stops at the breakpoint.


Sometimes I need to remove breakpoint, save scene to it be removed in fact. If I don't do that, every time I run startup command the breakpoint will be there.

Sometimes I need to close godot aplication to put break points. If not they don't stop. Sometimes only when the scene is running.

Sometimes it just don't stop no matter what I do.

Sometimes it shows the error when I put the breakpoint while running the Scene (ERROR: Condition "!breakpoint_list.find(breakpoint)" is true. Returning: Array()). Sometimes does not shows the error message.

Sometimes running the Scene it enable me to put breakpoint and the breakpoint stops (I run the scene in Godot using the button 'Run Project', it stopped and don't show vscode debug dialog box (continue, go next line, go inside), just stop at a line and I need to close the scene using the button 'Stop Running Project').

Sometimes I can put breakpoints but I can't remove (It is removed but when I play it is there).


Solution for now is using debugger inside Godot. It's much more consistent, and it removes the breakpoint when I want.

@DaelonSuzuka may I ask why isn't version 2.0 published to the extension store?

All issues from this thread are fixed there, but people keep coming and commenting on "workarounds".

@Exerionius I've been quite sick since late November and haven't completed everything I wanted to get done before publishing.

I did request the current state of the repo be published as 1.4.0 pre-release, so I will follow up on that today.

Well, I wish you getting well soon.

Thanks @Exerionius!

With the release of 2.0.0, this issue and surrounding discussion are outdated (and hopefully resolved).

Anybody who's experiencing problems with the new debugger should open new issues.

In case of anyone looking for C# workaround for debugging using Visual Studio Code, here is a basic boilerplate project:

https://github.com/guasam/godot-vscode-project