simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.16k stars 158 forks source link

.../dap/session.lua ENOENT when trying to debug #244

Closed Nikola-Milovic closed 2 years ago

Nikola-Milovic commented 2 years ago

Hello everyone, whenever I try to debug my code via the codeactions popup I get this error

Error executing vim.schedule lua callback: ...cal/share/nvim/site/pack/packer/opt/nvim-dap/lua/dap.lua:331: ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:959: ENOENT: no such file or directory                                                                              
stack traceback:                                                                                                                                                                                                                                                                            
        [C]: in function 'trigger_run'                                                                                                                                                                                                                                                      
        ...cal/share/nvim/site/pack/packer/opt/nvim-dap/lua/dap.lua:331: in function 'run'                                                                                                                                                                                                  
        ...pack/packer/start/rust-tools.nvim/lua/rust-tools/dap.lua:103: in function <...pack/packer/start/rust-tools.nvim/lua/rust-tools/dap.lua:74>                                 

My setup seems standard

My rust_tools setup

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)

local rt = require("rust-tools")

local extension_path = vim.env.HOME .. "/.vscode/extensions/vadimcn.vscode-lldb-1.6.7/"
local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = extension_path .. "lldb/lib/liblldb.so"

rt.setup({
    dap = {
        adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
    },
    tools = {
        inlay_hints = {
            auto = true,
            only_current_line = true,
            -- whether to show parameter hints with the inlay hints or not
            -- default: true
            show_parameter_hints = false,
        },
    },
    server = {
        on_attach = function(client, bufnr)
            vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })

            vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
        end,
    },
})

My dap installation

    use({
        "mfussenegger/nvim-dap",
        module = { "dap" },
        wants = { "nvim-dap-virtual-text", "nvim-dap-ui", "which-key.nvim" },
        requires = {
            "theHamsta/nvim-dap-virtual-text",
            "rcarriga/nvim-dap-ui",
            "nvim-telescope/telescope-dap.nvim",
            { "jbyuki/one-small-step-for-vimkind", module = "osv" },
        },
        config = function()
            require("nikola.dap").setup()
        end,
    })

My dap setup

local M = {}

local function configure()
    vim.fn.sign_define("DapBreakpoint", dap_breakpoint.error)
    vim.fn.sign_define("DapStopped", dap_breakpoint.stopped)
    vim.fn.sign_define("DapBreakpointRejected", dap_breakpoint.rejected)
end

local function configure_exts()
    require("nvim-dap-virtual-text").setup({
        commented = true,
    })

    local dap, dapui = require("dap"), require("dapui")
    dapui.setup({}) -- use default
    dap.listeners.after.event_initialized["dapui_config"] = function()
        dapui.open()
    end
    dap.listeners.before.event_terminated["dapui_config"] = function()
        dapui.close()
    end
    dap.listeners.before.event_exited["dapui_config"] = function()
        dapui.close()
    end
end

function M.setup()
    configure() -- Configuration
    configure_exts() -- Extensions
    require("nikola.dap.keymaps").setup() -- Keymaps
end

configure_debuggers()

return M

My nvim version

NVIM v0.8.0-dev+580-g45ba2e147

pato commented 2 years ago

I too am encountering this very same issue. I'm on MacOS, and I am using a Mason managed codelldb installation so my paths are slightly different and in my case I have liblldb.dylib instead of liblldb.so. But nonetheless I get the same error .

nvim version: NVIM v0.7.0 rust-tools version: let g:plugs['rust-tools.nvim'].commit = 'b696e6dee1e79a53159f1c0472289f5486ac31bc' nvim-dap version: let g:plugs['nvim-dap'].commit = 'ea25d6d7877558132e11ee9bcf099bf911cb25ac'

image
rnewton5 commented 2 years ago

Same issue here. Here's my config. https://github.com/rnewton5/neovim-config

My nvim-dap setup: https://github.com/rnewton5/neovim-config/blob/master/lua/plugins/configs/dap.lua My rust-tools setup: https://github.com/rnewton5/neovim-config/blob/master/lua/plugins/configs/lsp/init.lua#L21

I also ensure codelldb is installed at the locations specified.

rnewton5 commented 2 years ago

I figured out what it was for me.

for some reason using '~' to reference my home directory was causing issues. It was something I recently changed, but I didn't think it would be problematic.

So I changed:

  rust_tools.setup({
    -- other settings omitted for berevity...
    dap = {
      adapter = require('rust-tools.dap').get_codelldb_adapter(
        "~/.local/share/nvim/mason/packages/codelldb/extension/adapter/codelldb",
        "~/.local/share/nvim/mason/packages/codelldb/extension/lldb/lib/liblldb.so"
      )
    }
  })

to

  rust_tools.setup({
    -- other settings omitted for berevity...
    dap = {
      adapter = require('rust-tools.dap').get_codelldb_adapter(
        "/home/me/.local/share/nvim/mason/packages/codelldb/extension/adapter/codelldb",
        "/home/me/.local/share/nvim/mason/packages/codelldb/extension/lldb/lib/liblldb.so"
      )
    }
  })

and that fixed it. I don't think this is and issue with rust-tools btw. I also tried debugging directly with nvim-dap and received the same message when using '~' to reference my home directory.

@Nikola-Milovic, at a glance, it doesn't look like this'll help you because I believe vim.env.HOME == "/home/you" by default, but might want to print it out and see if that is the case or not.

simrat39 commented 2 years ago

Pretty sure OP has the wrong path for codelldb, and yeah, ~ doesn't work, hence the use of vim.env.HOME

simrat39 commented 2 years ago

@Nikola-Milovic please check if the path actually exists

Nikola-Milovic commented 2 years ago

@Nikola-Milovic please check if the path actually exists

Yep it was a path issue, its resolved now. The versions were different of the extension