Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debuggables uses wrong debugger #130

Closed
urso opened this issue Jan 6, 2024 · 1 comment · Fixed by #141
Closed

Debuggables uses wrong debugger #130

urso opened this issue Jan 6, 2024 · 1 comment · Fixed by #141
Labels
bug Something isn't working

Comments

@urso
Copy link

urso commented Jan 6, 2024

Neovim version (nvim -v)

NVIM v0.10.0-dev-ee21273

Operating system/version

macOS 14.2.1

Output of :checkhealth rustaceanvim

==============================================================================
rustaceanvim: require("rustaceanvim.health").check()

Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.

Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 1.77.0-nightly (3d0e6bed 2023-12-21)
- OK Cargo: found cargo 1.77.0-nightly (1a2666ddd 2023-12-17)
- OK rustc: found rustc 1.77.0-nightly (3d0e6bed6 2023-12-21)
- OK debug adapter: found codelldb 

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

How to reproduce the issue

I have lldb and my rust toolchain installed locally (via nix home-manager) and codelldb installed via mason. For that reason both `dap.adapters.lldb` and `dap.adapters.codelldb` is actually set in my system.

Expected behaviour

Start a debugging session with codelldb

Actual behaviour

Debugging session fails to start because of invalid arguments being passed to the debugger.

Debugging fails as it seems like the dap.adapter is set to codelldb, but the dap.configuration is set to:

local dap_config = {
        name = 'Rust debug client',
        type = 'lldb',
        request = 'launch',
        stopOnEntry = false,
}

And dap.adapters.lldb is not overwritten with adapter in dap.lua for this reason.

The minimal config used to reproduce this issue.

I'm using Lazy to setup my plugins. I have configured the `nvim-dap` to configure adapters for lldb and codelldb like so:


{
  {
    'mfussenegger/nvim-dap',
    dependencies = {
      'williamboman/mason.nvim',
    },
      local codelldb_root = mason_registry.get_package("codelldb"):get_install_path() .. "/extension/"
      local codelldb_path = codelldb_root .. "adapter/codelldb"
      local liblldb_path = codelldb_root .. "lldb/lib/liblldb.dylib"

      dap.adapters.codelldb = {
        type = 'server',
        port = "${port}",
        executable = {
          command = codelldb_path,
          args = { "--liblldb", liblldb_path, "--port", "${port}" },

          -- On windows you may have to uncomment this:
          -- detached = false,
        },
      }

      dap.adapters.lldb = {
        type = 'executable',
        command = vim.fn.exepath('lldb-vscode'),
        name = 'lldb',
      }
  },
  {
    "mrcjkb/rustaceanvim",
    version = "^3", -- Recommended
    ft = { "rust" },
    init = function()
      vim.g.rustaceanvim = {
        dap = {
          load_rust_types = false, # we don't need this when using codelldb
        },
      }
    end,
  },
}

I fixed the issue on my machine by changing the rustaceanvim configuration to:

  {
    "mrcjkb/rustaceanvim",
    version = "^3", -- Recommended
    ft = { "rust" },
    init = function()
      vim.g.rustaceanvim = {
        dap = {
          load_rust_types = false,
          configuration = {
            name = 'Rust debug client',
            type = 'codelldb',
            request = 'launch',
            stopOnEntry = false,
          },
        },
      }
    end,
  },

Alternatively removing dap.adapter.lldb from my setup works as well. Looks like the issue is with rustaceanvim trying to overwrite dap.adapter.lldb with the local adapter it has found. This leads to a conflict if dap.adapter.lldb is set already, but rustaceanvim has opted for codelldb.

@urso urso added the bug Something isn't working label Jan 6, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Jan 6, 2024

Hey 👋

Thanks for reporting.

It looks like your minimal config snippet got messed up.
Could you please correct it so that I can try to reproduce it when I have some time? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants