mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.11k stars 179 forks source link

Follow the exact instructions on :h dap-configuration to configure debugpy and it didn't work #1122

Closed Vinni-Cedraz closed 6 months ago

Vinni-Cedraz commented 6 months ago

Debug adapter definition and debug configuration

local dap = require("dap")
dap.configurations.python = {
    {
        type = "python",
        request = "launch",
        name = "Launch file",
        program = "${file}",
        pythonPath = function()
            return "/usr/bin/python"
        end,
    },
}

dap.adapters.python = {
    type = "executable",
    command = os.getenv("HOME") .. "/.local/share/nvim/mason/packages/debugpy/debugpy-adapter",
    args = { "-m", "debugpy.adapter" },
}

I tried doing basically the same for Go language and Javascript too (changing the names and paths appropriately) and it also didn't work. It only worked for c, cpp and dart.

Debug adapter version

No response

Steps to Reproduce

  1. install debugpy (or delve in the case of go) using Mason
  2. create a python.lua (or go.lua) file on ~/.config/nvim/ftplugin/ with the exact instructions you found on :h dap-configuration and dap-adapter
  3. use your pre-configured keymaps to set a break point and start a debug session
  4. cry in frustration because learning go, python and javascript is easier then setting dap to debug them

Expected Result

starting a debug session where I can set through the code as it was executed

Actual Result

(Python) - error message in orange: /home/myuser/.local/share/nvim/mason/packages/debugpy/debugpy-adapter exited with code: 2 (Go) - absolutely nothing happens

Vinni-Cedraz commented 6 months ago

I fixed this by commenting out the line as was suggested to me by someone on reddit

args = { "-m", "debugpy.adapter" },

However, I still don't understand why that line was causing me issues if I took it out from the exact example given on the documentation:

Screenshot_2023-12-26_19-15-39

mfussenegger commented 6 months ago

command = os.getenv("HOME") .. "/.local/share/nvim/mason/packages/debugpy/debugpy-adapter" points to some executable that probably wraps python -m debugpy.adapter, not the python interpreter.

Vinni-Cedraz commented 6 months ago

command = os.getenv("HOME") .. "/.local/share/nvim/mason/packages/debugpy/debugpy-adapter" points to some executable that probably wraps python -m debugpy.adapter, not the python interpreter.

Yes, because using the python interpreter: /usr/bin/python3 also didn't work. Didn't work either with or without the args.