Cannot to attach the remote dlv process #35
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
NeonXP/nvim-dap-go#35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Environment:
Steps to reproduce:
dlv debug -l 127.0.0.1:38697 --headless xxx/xxx.go7. Attach RemoteraisedError on attach: Failed to attach: no debugger found4. Attachand input 111 (111: id=1332739 name=dlv debug -l ...in the process list) and it raisedError on attach: Failed to attach: could not attach to pid 1332739: could not open debug info - debuggee must not be built with 'go run' or -ldflags='-s - w', which strip debug infoBTW
1. Debugworked fine but it surpressed the output.I don't know which part went wrong. Several days ago (before I update my system) I just need to run
dlv debug -l 127.0.0.1:38697 --headless xxx/xxx.goand select4. Attachand it would automatically find the remote process and attach to it.I'm having the same issue here. Did you get it to work? Some months ago I'm sure it worked, but now I'm getting this
Error on attach: Failed to attach: no debugger found.:lua = require('dap').configurations.goshowsand
:lua = require('dap').adapters.goNevermind, i think this is a dup of #27.
Adding the following made it work for me
This also stopped working for me (debugger not found) with the setup from the README:
For some reason dropping
initialize_timeout_secfixes it:I had this issue to:
I added this to my config to resolve my issue:
I believe it was saying it couldn't find the debugger because it didn't know which host and port to find the headless debugger.
This lead to another issue, I saw in nvim-dap-ui, the repl console was logging dlv couldn't start a headless server because the port was already in use. This is not the correct behavior because we are expecting to connect to a delve headless, not start one. I believe it's because the
executableis set:leoluz/nvim-dap-go@4af956c8ca/lua/dap-go.lua (L65)I did a hack around to stop this:
From
:h dap.txtAccording to this:
-- nvim-dap can optionally launch the debug-adapter on each new debug sessionwe should make this an option.
Wondering if a headless adapter is a possible solution:
This is really helpful. I have the problem too with the launching dlv instances and solved it differently by stopping them afterwards but this is much better!
Only, issue now is that if you want to debug a test for example it doesn't work anymore. Guess I'll add a function to toggle between the two modes but this needs a fix.
There haven't been any commits and issues/PRs look stale though not sure if this plugin is still maintained @leoluz ?
Yeah I figured that'll break that😵😞. Hence, a separate adapter for headless debug servers. Apart from that, I had issues with the attach. Though the go adapter is configured to start the server, the process doesn't get kicked off and I don't see it's pid. And, if I do start a dlv process in headless mode, and attach to its pid via nvim dap, I get an error saying the debug session is already in progress at port 8181 and instead use remote mode to connect to the server. I wonder if the go adapter for attach should be setup as an executable, which can start the server, and we'll see it's pid from nvim dap. Additionally, the attach configuration is changed from local to remote mode.
Update: I tried and the process is not starting.
Welp, it's probably best to go with headless adapter
What works for me right now is setting up nvim-dap like this:
And starting the debug server with:
while pkill dlv; dlv debug -l 127.0.0.1:38697 --headless ./cmd/main.go; do echo "restarting delve..."; doneSo it kills off the dlv started by nvim locally first. Of course this is suboptimal but I didn't have the time to really look into this. But that way both work, attaching to remote or starting one up for test debugging etc.
@marcomayer Yes it is and I use it often :) I work on it when I have time.
I am also open for PRs and help from the community to do issue triage.
@marcomayer Please feel free to suggest a solution to the problem that you are having.
FWIW, this config works without the pkill hack:
Debug test + attach remote both work.
I don't use the remote debug feature and I am not sure if there is still an issue with clashing dlv instances running in the same port or not.
Can someone please confirm so I can close this issue?
I haven't seen it, as one data point.
It wasn't a perfect test, but I just now started a remote and connected to it with htop open (filtered to 'dlv') and didn't see any extras pop up.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@psethwick 's config worked for me in-so-far as the connection was made to the remote Delve. However, the listener couldn't be started because the port is in use.
couldn't start listener: listen tcp 127.0.0.1:45000: bind: address already in useI have a number of containerized Go services, and each can run delve on a diferent port. IDEs such as Vscode (config below) and Goland can attach to these processes
VSCode debug config:
Ideally, the dap_configuration would handle different ports for different configuration entries too.
Any help welcome! If I get this working I'll be sure to report back here.
@paulbrittain Thank you for your investigation. I am closing this for now. Please feel free to reopen if the issue persists.
fwiw I'm getting the exact same issue. seems like somehow the plugin is both trying to attach and start it's own headless dlv process?
When I attach I get a warning that
dlv exited with code 1but the UI and logs from my debug process show that I'm attached. Breakpoints do not pause, the repl doesn't give any accurate info.@stevenctl I'm running into the same issue. I was able to track it down to likely this commit:
leoluz/nvim-dap-go@bd9823da22There was a custom delve adapter with a callback and it started using the builtin
nvim-dapadapter, but thenvim-dapadapter doesn't seem to look at therequesttype before it determines what it does. I tracked it to this call here. It callsattachwhich I thought was a strange name, but this then callsconnecthere and the connect method seems to always launch the executable if the executable is set.The only way I can see to fix it is to use the
enrich_configto exclude the executable when the request isattachin this plugin or potentially modify this innvim-dap.I just started using nvim maybe last week though so I'm not sure where to make the change upstream or how to modify this locally. @leoluz I'd like to make a PR for this if I can get some guidance on where the change should be made. I use remote debugging pretty frequently by attaching to a delve server inside of a docker container.