dap-buddy.nvim icon indicating copy to clipboard operation
dap-buddy.nvim copied to clipboard

Issues getting started with debugpy - unable to launch debug session

Open bavalpey opened this issue 3 years ago • 5 comments

I've been using this plugin along with nvim-dap=ui and I'm having serious issues getting this working on a very simple example. I've put the settings to configure dap as mentioned in the README in ftplugin/python.lua

file: ftplugin/python.lua

local dap_install = require("dap-install")
dap_install.config(
	"python",
    {
        adapters = {
            type = "executable",
            command = "python",
            args = {"-m", "debugpy.adapter"}
        },
        configurations = {
            {
                type = "python",
                request = "launch",
                name = "Launch file",
                program = "${file}",
                pythonPath = function()
                    local vnv = os.getenv("VIRTUAL_ENV")
                    if vnv ~= nil and vim.fn.executable(vnv .. "/bin/python") then
                        return vnv .. "/bin/python"
                    else
                        return "/usr/bin/python"
                    end
                end
            }
        }
    }
)

I've created a hello_world python module, set a breakpoint, and called :lua require'dap'.continue() After some time, that results in the following message: Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your adapter or `python` configuration. Check the logs for errors (:help dap.set_log_level)

What am I doing wrong? How can I get this to be properly configured. It is also worth noting that I tried to just run the debugger out-of-the-box after running DIInstall, but this failed, stating that python was not configured.

bavalpey avatar Nov 04 '21 17:11 bavalpey

Huh weird, it was the first debugger I got working. Keep in mind that configs are not "fetched", they are hard coded, so yeah if you did everything well then it's likely a problem with the config just being outdated.

So please:

  1. Try without passing any config, just let DAPInstall use the default config.
  2. Try 1 + instead of putting the snippet above under ftplugin/, put it under lua/ and make your package manager load nvim-dap, then DAPInstall and then this config.
  3. Try 1 and 2 + using the current config from nvim-dap.

pocco81 avatar Nov 04 '21 18:11 pocco81

Hmm.. It's very strange to me; solution 1 just worked fine. Do you have any suggestions for configuring it to work when a virtual environment is actually active? Those relative path checks included in the default configuration are worthless.

Also, question, if I change the value of dap_install.config, will that effect the configuration of the debugger after it is installed? Or is the config applied only at time of install?

bavalpey avatar Nov 04 '21 19:11 bavalpey

Also, question, if I change the value of dap_install.config, will that effect the configuration of the debugger after it is installed? Or is the config applied only at time of install?

neither, it's applied at runtime. Nvim-dap is the one in-charged of that, DAPInstall only hands the debuggers' config to it :)

pocco81 avatar Nov 05 '21 21:11 pocco81

I'm in the same boat. Only the default configuration works. Is there a way to print out this default config so we can try modifying that?

ByteDrummer avatar Jan 13 '22 00:01 ByteDrummer

Setting dap.configurations.python after calling dap_install.config("python", {}) works fine for me so I guess for now I'll do my configuration directly through nvim-dap.

ByteDrummer avatar Jan 13 '22 23:01 ByteDrummer