pocco81 / dap-buddy.nvim

🐞 Debug Adapter Protocol manager for Neovim
GNU General Public License v3.0
399 stars 48 forks source link

Issues getting started with debugpy - unable to launch debug session #45

Open bavalpey opened 2 years ago

bavalpey commented 2 years ago

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.

pocco81 commented 2 years ago

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.
bavalpey commented 2 years ago

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?

pocco81 commented 2 years ago

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 :)

ByteDrummer commented 2 years ago

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 commented 2 years ago

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.