-
Notifications
You must be signed in to change notification settings - Fork 78
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
Substitute paths when connecting to remote headless dlv
server
#43
Comments
I am not a user of launch.json
|
@nnarayen I am also unaware of such configuration. Have you tried asking in the nvim-dap project? |
I was able to set the It requires some ingenuity as the local dap_go = require('dap-go')
local dap = require('dap')
dap_go.setup()
table.insert(dap.configurations.go, {
type = 'delve',
name = 'Attach remote',
mode = 'remote',
request = 'attach',
substitutePath = {
{ from = '${workspaceFolder}', to = '/app' },
},
})
dap.adapters.delve = {
type = 'server',
host = 'localhost',
port = '38697'
} It works like this. |
Hi, debug in remote container in Kubernetes works fine for me. Here is the full plugin config for {
"leoluz/nvim-dap-go",
opts = {
dap_configurations = {
{
-- Must be "go" or it will be ignored by the plugin
type = "go",
name = "Connect remote",
request = "attach",
mode = "remote",
substitutePath = {
{
from = "${workspaceFolder}",
to = "/app",
},
},
},
},
delve = {
port = 2345,
},
},
},
I use 2345 port for communication with dlv, so my command in remote container is dlv debug --headless --listen=:2345 --log --api-version=2 |
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. |
I can confirm that setup given from @ryutah works fine for me to debug in a remote container. In my case I use Dockerfile: FROM golang:1.20-bullseye
WORKDIR /wd
COPY go.mod .
COPY go.sum .
RUN go mod download -x
RUN go install github.com/go-delve/delve/cmd/dlv@latest
COPY . .
CMD ["dlv", "debug", "--listen=:34567", "--headless", "--build-flags='-buildvcs=false'"] nvim setup: local dap_go = require('dap-go')
local dap = require('dap')
dap_go.setup()
table.insert(dap.configurations.go, {
type = 'delve',
name = 'Container debugging (/wd:34567)',
mode = 'remote',
request = 'attach',
substitutePath = {
{ from = '${workspaceFolder}', to = '/wd' },
},
})
dap.adapters.delve = {
type = 'server',
host = 'localhost',
port = '34567'
} docker-compose: version: '3'
services:
app:
container_name: my-app
hostname: my-app
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
- '34567:34567'
restart: unless-stopped
volumes:
- ./:/wd |
I'm currently using
nvim-dap
andnvim-dap-go
to connect to a headlessdlv
server running remotely in k8s. Unfortunately, the source code during compilation of the remote binary is different than my local source code, so by default most breakpoint functionality does not work.As far as I understand, path transformations occur client side and not on the
dlv
server. I can get this to work viadlv connect
on my local machine either withconfig substitute-path <from> <to>
or via thedlv
config.yml file. Unfortunately, I haven't found a way to have the nvim dap client perform any path substitutions.This issue is more of an open question, but do you know if that's currently possible? Thanks in advance!
Build information
Remote
dlv
servernvim-dap
: v0.5.0nvim-dap-go
: shab4ded7de579b4e2a85c203388233b54bf1028816
The text was updated successfully, but these errors were encountered: