mfussenegger / nvim-dap-python

An extension for nvim-dap, providing default configurations for python and methods to debug individual test methods or classes.
GNU General Public License v3.0
492 stars 46 forks source link

Error running [...]/.local/share/nvim/mason/packages/debugpy/venv/bin/python: ENOENT: no such file or directory #107

Closed nyngwang closed 1 year ago

nyngwang commented 1 year ago

I got this error:

   Error  12:36:38 msg_show.lua_error Error executing vim.schedule lua callback: /Users/ningwang/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:493: ...wang/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1329: Error running /Users/ningwang/.local/share/nvim/mason/packages/debugpy/venv/bin/python: ENOENT: no such file or directory
stack traceback:
    [C]: in function 'trigger_run'
    /Users/ningwang/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:493: in function 'run'
    /Users/ningwang/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:406: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>

This is my setup:

use {
  'mfussenegger/nvim-dap-python',
  dependencies = { 'mfussenegger/nvim-dap' },
  config = function ()
    local dappy = require('dap-python')
    dappy.setup('~/.local/share/nvim/mason/packages/debugpy/venv/bin/python')
    vim.keymap.set('n', '<Leader>dppm', function () dappy.test_method() end, G.NOREF_NOERR_TRUNC)
    vim.keymap.set('n', '<Leader>dppc', function () dappy.test_class() end, G.NOREF_NOERR_TRUNC)
    vim.keymap.set('x', '<Leader>dppx', function () dappy.debug_selection() end, G.NOREF_NOERR_TRUNC)
  end
}

I installed debugpy with mason.nvim.

mfussenegger commented 1 year ago

The error is pretty clear:

 Error running /Users/ningwang/.local/share/nvim/mason/packages/debugpy/venv/bin/python: ENOENT: no such file or directory
nyngwang commented 1 year ago

Hi, sorry for not being clear about the situation. The following message is optional, I just want to say that I'm responsible for all issues I created here.

When I encountered this bug, I did read the error message and checked that indicated path, i.e. ~/.local/share/nvim/mason/packages/debugpy/venv/bin/python. The file exists. The dashboard of mason.nvim did show that I have debugpy installed. I also tried to cd into the folder to see what's going on. Finally, I resolved this hours ago by reinstalling everything inside the folder ~/.local, renaming some files I require(...) in my config, and restarting Neovim many times. It seems that it was "renaming some files I require(...)" that solves this problem, and I believe this could be related to the caching mechanism of lazy.nvim, not sure.

I planned to close this issue with not just the solution but also the insight to help any future user who will probably also run into this situation(since both plugins: lazy & mason are the most popular solutions recently). Anyway, hope you didn't get annoyed by this issue. I just want to let you know I'm responsible for it. If I can find the reason that caused this problem, I will add comments here for reference.

owod24 commented 5 months ago

Hi there, i'm currently facing this issue, can you go into more detail on how to solve it? I have checked to see if i spelt everything correctly and have restarted neovim multiple times but i still get the error message.

mairs8 commented 5 months ago

so am i

nyngwang commented 5 months ago

@owod24 @mairs8 Try avoid using the ~ shorthand(I'm still not sure). This is what I currently have in my dotfiles:

dappy.setup(vim.fn.stdpath('data') .. '/mason/packages/debugpy/venv/bin/python')