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

The "remote" example from the README doesn't appear to work #105

Open
aktau opened this issue Dec 9, 2024 · 3 comments
Open

The "remote" example from the README doesn't appear to work #105

aktau opened this issue Dec 9, 2024 · 3 comments

Comments

@aktau
Copy link

aktau commented Dec 9, 2024

From the README:

lua require('dap-go').setup {
  dap_configurations = {
    {
      type = "go",
      name = "Attach remote",
      mode = "remote",
      request = "attach",
    },
  },
}

So I tried to connect to a running dlv dap, and it connects alright (after I hard-code the port), but then immediately I get that dlv exits with code 1. After reading nvim-dap docs, I figure this is due to the following:

local delve_config = {
type = "server",
port = config.delve.port,
executable = {
command = config.delve.path,
args = args,
detached = config.delve.detached,
cwd = config.delve.cwd,
},
options = {
initialize_timeout_sec = config.delve.initialize_timeout_sec,
},
}
.

As it turns out, if an executable attribute is set, mfussenegger/nvim-dap will spawn that executable, even when request = "attach". This is incognruent with mode = "remote". Docs: https://github.com/mfussenegger/nvim-dap/blob/580d6e526358afd0e4bba053e68fd59cf581a161/doc/dap.txt#L76-L78.

So I fixed my problem by commenting out that executable section. It'd probably make sense to make this executable section depend on whether or not mode == "remote".

@Nalum
Copy link

Nalum commented Feb 11, 2025

I've opened an PR to fix this, just waiting for review and merge.

@dennypenta
Copy link

I think think it's related, but I struggle to connect to a debugger server in general.
I try config:

    {
      "type": "go",
      "name": "debug remote service",
      "mode": "remote",
      "request": "attach",
      "port": 40000,
      "host": "localhost"
    },

and it gives me "Failed to attach: no debugger found".
I tried the branch of @Nalum, didn't work for me.
I guess I just have a wrong config, right?
the dap port is exposed from a local docker image, I can connect from jetbrains, so the debugger server itself is correct for sure.

@dennypenta
Copy link

I found an issue, the port value is ignored from vscode config and is taken from dap.adapters.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants