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

Support path for lldb-vscode executable from PATH variable #4492

Open
gracicot opened this issue Feb 5, 2024 · 7 comments
Open

Support path for lldb-vscode executable from PATH variable #4492

gracicot opened this issue Feb 5, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@gracicot
Copy link

gracicot commented Feb 5, 2024

Problem description

When I try to debug my C++ project (using <leader>ds), I get this error:

...lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap/session.lua:1420: Error running /usr/bin/lldb-vscode: ENOENT: no such file or directory
stack traceback:
^I[C]: in function 'error'
^I...lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap/session.lua:1420: in function 'spawn'
^I...l/share/lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap.lua:1041: in function 'launch'
^I...l/share/lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap.lua:373: in function 'run_adapter'
^I...l/share/lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap.lua:408: in function 'maybe_enrich_config_and_run'
^I...l/share/lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap.lua:504: in function <...l/share/lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap.lua:488>
^I[C]: in function 'xpcall'
^I...e/lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap/async.lua:12: in function <...e/lunarvim/site/pack/lazy/opt/nvim-dap/lua/dap/async.lua:11>
Press ENTER or type command to continue

I don't have an executable /usr/bin/lldb-vscode, but I do have lldb-vscode in my path:

❯ lldb-vscode
Content-Length: 205

{"body":{"category":"stderr","output":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nModuleNotFoundError: No module named 'lldb'\n"},"event":"output","seq":0,"type":"event"}

LunarVim version

master-e85637c2

Neovim version (>= 0.9.1)

NVIM v0.9.4

Terminal name

iTerm2

Operating system/version

macOS 14.2 (23C64)

Steps to reproduce

  1. Install lldb-vscode using a package manager like brew, nix, macports etc with the llvm distribution. The problem arise if the package manager don't copy/link to /usr/bin
  2. Run the debugger in vim, default binding is <leader>ds
  3. Observe vim trying to call a fixes absolute path /usr/bin/lldb-vscode instead of the lldb-vscode in PATH

Screenshots

No response

@gracicot gracicot added the bug Something isn't working label Feb 5, 2024
Copy link
Contributor

This issue is stale because it has been open for 50 days with no activity.

@github-actions github-actions bot added the stale label Mar 27, 2024
@gracicot
Copy link
Author

Well, I'm still affected by the issue. No one addressed it yet and I'm still looking for workarounds.

@github-actions github-actions bot removed the stale label Mar 28, 2024
@juicy-g
Copy link
Contributor

juicy-g commented Apr 27, 2024

Can you post your DAP config? You may need to provide the path of the debugger to your adapter since it's installed externally (not through Mason).

@gracicot
Copy link
Author

@juicy-g I'm just using the default lunarvim config. I haven't seen documentation how to change lunarvim's config for DAP.

@juicy-g
Copy link
Contributor

juicy-g commented Apr 28, 2024

Lunarvim doesn't configure the debug adapter for you. I have never used C++, but this is what I would try in my config.lua:

lvim.builtin.dap.on_config_done = function(dap)
 dap.adapters.lldb = {
    type = 'executable',
    command = 'lldb-vscode', -- absolute path to lldb-vscode here
    name = 'lldb'
  }

  dap.configurations.cpp = {
    {
      name = 'Launch',
      type = 'lldb',
      request = 'launch',
      program = function()
        return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
      end,
      cwd = '${workspaceFolder}',
      stopOnEntry = false,
      args = {},
    },
  }
end

See this page for more information on how to configure DAP and the adapter: https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#ccrust-via-lldb-vscode

@relief-melone
Copy link

same issue. I am using nixos and I remember my setup to have been working in the past (still not counting out I messed up something unnoticed along the way). My config looks more or less exactly the same ;) guess we found it in the same spot

@juicy-g
Copy link
Contributor

juicy-g commented May 19, 2024

I found that lldb-vscode was renamed to lldb-dap a few months ago: https://discourse.llvm.org/t/rfc-rename-lldb-vscode-to-lldb-dap/74075.

When I install LLVM using linuxbrew, the lldb-dap executable appears in /home/linuxbrew/.linuxbrew/bin.

I would change this part of the config above to suit however you are installing LLVM. For example:

dap.adapters.lldb = {
    type = 'executable',
    command = '/home/linuxbrew/.linuxbrew/bin/lldb-dap',
    name = 'lldb'
  }

It seems to work for me.

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

No branches or pull requests

3 participants