Closed steve21168 closed 11 months ago
I would expect that since I'm making an attach request and not a launch request that the executable in the adapter configuration would not be called.
The configuration & request type doesn't control how to connect to the adapter, but rather it tells the adapter what it should do. The adapter definition controls how to connect to the adapter.
If you include a executable
block it launches an executable.
nvim-dap can't be smart about this and assume that if you used a attach
, you don't want an executable because some debug adapters may actually require the executable. Often a debug adapter is used to act as an adapter from DAP to another protocol. E.g. in Java/JVM the communication looks like this:
┌──────────┐ DAP ┌─────────────┐ JDWP ┌────┐
│ nvim-dap ├──────►│debug adapter│───────► │JVM │
└──────────┘ └─────────────┘ └────┘
If you know that you're connecting to an already running debug adapter, you need to modify the adapter accordingly. E.g. something like this:
dap.adapters.ruby = function(callback, config)
if config.request == "attach" then
callback {
type = "server",
-- or use host/port from config
host = "127.0.0.1",
port = "9797",
}
else
callback {
type = "server",
host = "127.0.0.1",
port = "9797",
executable = {
command = "bundle",
args = { "exec", "rdbg", "-n", "--open", "--port", "9797",
"-c", "--", "bundle", "exec", config.command, config.script,
},
},
}
end
end
Debug adapter definition and debug configuration
Copied straight from the docs:
Debug adapter version
d17d1bba23ec72a157bd183c57840c39e323f515
Steps to Reproduce
foo.rb
rdbg -O --port 9797 -c -- ruby foo.rb
:DapContinue
to trigger the dap attach requestExpected Result
I would expect that since I'm making an attach request and not a launch request that the executable in the adapter configuration would not be called. Because it is called the executable errors. The attach portion works as intended.
Actual Result
I see an error that the executable application crashed in the vim cmd line window and then I can see an error when I open the REPL. The crash makes sense, as it was not intended to run the executable command in this context. The attach works fine as it worked as intended.
The issue is that from my understanding and attach request should only use the server portion to connect to the existing dap server.