Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Cannot debug or debug test with Remote-WSL #2505

Closed
davidovich opened this issue May 8, 2019 · 33 comments
Closed

Cannot debug or debug test with Remote-WSL #2505

davidovich opened this issue May 8, 2019 · 33 comments
Labels
debug vscode-remote Issues found when working with vscode-remote

Comments

@davidovich
Copy link

When I try to start a debug session (through codelens for tests or with a launch configuration, the debug session fails rapidly with this outpout (I have enabled "trace" : "log" in the launch configuration):

Verbose logs are written to:
/tmp/vscode-go-debug.txt
InitializeRequest
InitializeResponse
Using GOPATH: /home/david/go
Current working directory: /f/dev/[redacted-project-path]
Running: /home/david/go/bin/dlv debug --headless=true --listen=127.0.0.1:49709 --api-version=2 -- [redacted params]
# runtime/cgo
exec: "gcc-5": executable file not found in $PATH
exit status 2
Process exiting with code: 1
Sending TerminatedEvent as delve is closed

I installed gcc@5 with linuxbrew:

which gcc-5
/home/linuxbrew/.linuxbrew/bin/gcc-5

Running the above dlv command in my terminal works, which points to the PATH env var not being populated in the calling proccess.

This may be related to #2504.

@davidovich
Copy link
Author

davidovich commented May 9, 2019

Note that I have resolved the gcc-5 problem, it is related to the fact that I was setting my path in ~/.profile which is not sourced by bash -i (which is used to start the wsl-host process).

Moving the PATH setup to ~/.bashrc fixes this problem.

But I am still not able to debug, the dlv process just hangs indefinitely.

Delve does not seem to support debugging in WSL right now.

Related:
microsoft/WSL#2028 (comment)

@chathamws
Copy link

I can confirm this same behavior also exists in my own testing. The Debugger just hangs with the message "API server listening at: 127.0.0.1:18198" in the Debug Console. My path settings are correct and I can execute my go program successfully using Ctrl+F5 "Start without Debugging". This issue only seems to be related to the debugger.

@JanDeDobbeleer
Copy link

It would be nice if there's someone smarter than myself who can provide a workaround for this one (if available).

@ramya-rao-a ramya-rao-a added debug vscode-remote Issues found when working with vscode-remote labels Jun 29, 2019
@schaefec
Copy link

I experience the exact same issue: Works fine running w/o debugging (CTR+F5) but doesn't work with debugging (F5)

@developeer
Copy link

developeer commented Jul 18, 2019

I have run into this also. the trace: verbose everything looks good but never hits my first breakpoint in main. In the debug console, it has a link to the file I am debugging. I click on it and it says it does not exist and prompts to create it which is not right. I am using gvm (to install go 1.12.5). I am trying to debug kubernetes/kubectl. Works fine w/o debugging as others have stated. I am currently comparing the debug session with debugging directly on ubuntu 18.04.

Also if you change the launch.json settings to include trace: verbose and logOutput: true you will see that the debugger fails because it can't find the source file for the breakpoint.

running wsl on win 10 - 1803.

@ghost
Copy link

ghost commented Jul 19, 2019

The same problem... As far as I understand the issue should be solved by #926 . Today I installed a fresh version of VSC Insiders on my Windows 10 machine. I also installed Remote Development and Go extensions(the second one on WSL).When I try to debug it just hangs

@JcgGOs
Copy link

JcgGOs commented Jul 26, 2019

The same problem

when i press(F5) the debugger is hang. below is my trace log

Verbose logs are written to:
/tmp/vscode-go-debug.txt
InitializeRequest
InitializeResponse
Using GOPATH: /home/tao/go
Current working directory: /home/tao/go/src/xxx.com/xx/xx
Running: /home/tao/go/bin/dlv debug xxx.com/xx/xx --headless=true --listen=127.0.0.1:39657 --api-version=2 --log=true -- v=6 log_dir=~/logs/xxxxx/ alsologtostderr=true
API server listening at: 127.0.0.1:39657
2019-07-26T14:14:45+08:00 info layer=debugger launching process with args: [/home/tao/caterpillar/app/__debug_bin v=6 log_dir=~/logs/xxxxx/ alsologtostderr=true]
InitializeEvent
ConfigurationDoneRequest
ContinueRequest
ContinueResponse

i run main.go in my workspace,it work well

go version go1.12.7 linux/amd64
Go for Visual Studio Code:0.11.4
VSCODE
Version: 1.36.1 (user setup)
Commit: 2213894ea0415ee8c85c5eea0d0ff81ecc191529
Date: 2019-07-08T22:59:35.033Z
Electron: 4.2.5
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

@surenderssm
Copy link
Member

Experiencing same issue.

  • Start without debugging (Ctlr+F5) works fine.
  • Start debugging (F5) - just hangs indefinitely with following message in Debug Console

image

@OhYee
Copy link

OhYee commented Sep 7, 2019

Maybe we can use gdb instead of delve, before delve works in wsl.

The tasks.json and launch.json as below can work well through native debug extension

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "compile",
            "type": "shell",
            "command": "go build -gcflags=all=\"-N -l\" ${workspaceFolder}/${relativeFile}"
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gdb",
            "request": "launch",
            "name": "Launch Program",
            "target": "${workspaceFolder}/${fileBasenameNoExtension}",
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText",
            "preLaunchTask": "compile"
        }
    ]
}

@hisfei
Copy link

hisfei commented Sep 19, 2019

Experiencing same issue.

  • Start without debugging (Ctlr+F5) works fine.
  • Start debugging (F5) - just hangs indefinitely with following message in Debug Console

image

Have you solved the problem yet?

@wizcas
Copy link

wizcas commented Sep 20, 2019

Is there any news on this? Or is there something can be done as a workaround? It's so annoying that debugging is not functional when really needed.

@davidovich
Copy link
Author

@wizcas I have had some success with Remote-Containers and go image. This sidetracks the WSL problem, but at least you can debug. Be sure to start code in a Windows drive.

@wizcas
Copy link

wizcas commented Sep 20, 2019

@davidovich the idea is cool! I'm gonna try it definitely, as it also keep everyone's dev environment identical. Thanks!

@promaty
Copy link

promaty commented Sep 23, 2019

Still no luck in v1.38.1

@hecsalazar
Copy link

Same problem: when I start debugger it just shows the message:
API server listening at: 127.0.0.1:48931

@hecsalazar
Copy link

Added verbose tracing in .vscode/launch.json configuration by setting showLog and trace properties:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${fileDirname}",
            "env": {},
            "args": [],
            "showLog": true,
            "trace": "verbose"
        }
    ]
}

Log on launch:

To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"API server listening at: 127.0.0.1:2345\n"}}
API server listening at: 127.0.0.1:2345
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"2019-09-26T11:36:53-04:00 info layer=debugger launching process with args: [/home/hsalazar/go/src/{redacted}/__debug_bin]\n"}}
2019-09-26T11:36:53-04:00 info layer=debugger launching process with args: [/home/hsalazar/go/src/{redacted}/__debug_bin]
To client: {"seq":0,"type":"event","event":"initialized"}
InitializeEvent
To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":true}
From client: setExceptionBreakpoints({"filters":[]})
To client: {"seq":0,"type":"response","request_seq":3,"command":"setExceptionBreakpoints","success":true}
From client: configurationDone(undefined)
ConfigurationDoneRequest

At this point nothing else happens.

When I stop the debugger this is added to the previous log:
From client: disconnect({"restart":false}) DisconnectRequest HaltRequest

@bingoIsCoder
Copy link

same issue. is there any update?

@steve-offutt
Copy link

I am also experiencing this same behavior. VSCode hangs indefinitely when debugging via WSL Remote Connection.

@eduardpaul
Copy link

Hello everyone! Same issue here in wsl1 ubuntu 18 :( We tried @OhYee native debugger approach but the result was a very poor debugging experience: lag, interruptions, no information about struct contents...

By now I will be using containers where debugging is working great and building a go dev container was a very simple task:

Also, people say that using wsl2 solves the problem.

@khowling
Copy link

khowling commented Oct 9, 2019

+me, same problem

@NVD-R
Copy link

NVD-R commented Oct 20, 2019

Same problem!!!
is there any solution?

@guodf
Copy link

guodf commented Oct 22, 2019

Me too!

@c3y28
Copy link

c3y28 commented Oct 25, 2019

Still in v1.39.2

@sgyy
Copy link

sgyy commented Oct 28, 2019

v1.39.2
Me too!

@lcl101
Copy link

lcl101 commented Oct 29, 2019

v1.39.2
Me too!!

@lcl101
Copy link

lcl101 commented Oct 29, 2019

From client: setBreakpoints({"source":{"name":"main.go","path":"/mnt/d/work/wf/go/src/github.com/lcl101/mytest/test1/main.go"},"lines":[8],"breakpoints":[{"line":8}],"sourceModified":false})
SetBreakPointsRequest
stop here

@lcl101
Copy link

lcl101 commented Oct 29, 2019

wsl messsage:
licl 4927 4749 0 10:37 tty3 00:00:00 /home/licl/.vscode-server/bin/6ab598523be7a800d7f3eb4d92d7ab9a66069390/node /home/licl/.vscode-server/extensions/ms-vscode.go-0.11.7/out/src/debugAdapter/goDebug.js
licl 4938 4927 0 10:37 tty3 00:00:01 /mnt/d/work/sf/go/bin/dlv debug github.com/lcl101/mytest/test1 --headless=true --listen=127.0.0.1:45905 --api-version=2 --log=true
licl 5002 4938 0 10:37 tty3 00:00:00 /mnt/d/work/wf/go/src/github.com/lcl101/mytest/test1/__debug_bin

@kuskmen
Copy link

kuskmen commented Nov 7, 2019

I don't think it will be very much helpful but I hope at least it gets some attention by saying that this still doesn't work

Version: 1.40.0 (system setup)
Commit: 86405ea23e3937316009fc27c9361deee66ffbf5
Date: 2019-11-06T17:02:13.381Z
Electron: 6.1.2
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18362

@hyungjic
Copy link

hyungjic commented Nov 8, 2019

Same here, it worked on previous versions(not sure about the specific version numbers though), but it stopped working on the latest version. Interesting thing is that it's still working with 'Remote-SSH'

Version: 1.40.0 (user setup)
Commit: 86405ea23e3937316009fc27c9361deee66ffbf5
Date: 2019-11-06T17:02:13.381Z
Electron: 6.1.2
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.17763

And this trace looks suspicious...

--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (296) Failed to create fifo\n"},"seq":26}
1: (296) Failed to create fifo

@tczee36
Copy link

tczee36 commented Nov 13, 2019

why is this message showing up in default setting anyways?

@promaty
Copy link

promaty commented Dec 17, 2019

I figured out the problem. Go dlv debugger uses some system calls that are not supported in WSL1. Remember that WSL1 just uses a small Linux emulation layer while trying to translate Linux system calls to Windows.

WSL2 contains a fully fledged Linux kernel with full system call compatibility. However it's currently in beta and is only available with Windows insiders build (general availability sometime in 2020).

However you can install it right now by joining insiders which I highly recommend, works very well: https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

In WSL2 go debugging works without issues. Also you can run any Linux program natively (Docker containers, kubernetes, etc.)

@quoctruong
Copy link
Contributor

Since WSL2 is working with this, I think we can close the bug @ramya-rao-a?

@ramya-rao-a
Copy link
Contributor

Thanks for the update @promaty!

@vscodebot vscodebot bot locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug vscode-remote Issues found when working with vscode-remote
Projects
None yet
Development

No branches or pull requests