puremourning / vimspector

vimspector - A multi-language debugging system for Vim
http://puremourning.github.io/vimspector-web
Apache License 2.0
4.08k stars 171 forks source link

NVim Lazy vimspector `vim/_editor.lua:0: nvim_exec2(): Vim(packadd):E919: Directory not found in 'packpath': "pack/*/opt/vimspector" #845

Closed MikeLemo1 closed 5 months ago

MikeLemo1 commented 5 months ago

Description

I might be doing something wrong with my setup but then only way I can get spector started in nvim is by using the command <cmd>VimspectorUpdate<cr> and then it put the following message: Failed to run config for vimspector

vim/_editor.lua:0: nvim_exec2(): Vim(packadd):E919: Directory not found in 'packpath': "pack/*/opt/vimspector"

stacktrace:

Is it reproducible in vim?

Only broken in Neovim

Works with clean config?

Yes

Sample project works?

Not reproducible with sample project

Minimal Reproduction

List of steps to reproduce:

  1. Run vim ---clean Nu /path/to/vimspector/support/minimal_vimrc ....
  2. Open this project...
  3. Press this sequence of keys

Expected Behaviour

load the vimspector.json file and start the debugger with <cmd>call vimspector#Launch()<cr>

Actual Behaviour

E117: Unknown function: vimspector#Launch OR

Failed to run config for vimspector

vim/_editor.lua:0: nvim_exec2(): Vim(packadd):E919: Directory not found in 'packpath': "pack/*/opt/vimspector"

stacktrace:

after <cmd>VimspectorUpdate<cr> that temporarly for the session fixes it.

Additional information

my config: ~/.config/nvim/lua/config/vimspector.lua

local function debuggers()
  vim.g.vimspector_install_gadgets = {
    "debugpy", -- Python
    "local-lua-debugger-vscode",
  }
end

local M = {
  "puremourning/vimspector",
  cmd = { "VimspectorInstall", "VimspectorUpdate" },
  fn = { "vimspector#Launch()", "vimspector#ToggleBreakpoint", "vimspector#Continue" },
}

local utils = require "utils"

local vimspector_python = [[
{
  "configurations": {
    "<name>: Launch": {
      "adapter": "debugpy",
      "configuration": {
        "name": "Python: Launch",
        "type": "python",
        "request": "launch",
        "python": "%s",
        "stopOnEntry": true,
        "console": "externalTerminal",
        "debugOptions": [],
        "program": "${file}"
      }
    }
  }
}
]]

--- Generate debug profile. Currently for Python only
function M.generate_debug_profile()
  -- Get current file type
  local buf = vim.api.nvim_get_current_buf()
  local ft = vim.api.nvim_buf_get_option(buf, "filetype")

  if ft == "python" then
    -- Get Python path
    local python3 = vim.fn.exepath "python"
    local debugProfile = string.format(vimspector_python, python3)

    -- Generate debug profile in a new window
    vim.api.nvim_exec("vsp", true)
    local win = vim.api.nvim_get_current_win()
    local bufNew = vim.api.nvim_create_buf(true, false)
    vim.api.nvim_buf_set_name(bufNew, ".vimspector.json")
    vim.api.nvim_win_set_buf(win, bufNew)

    local lines = {}
    for s in debugProfile:gmatch "[^\r\n]+" do
      table.insert(lines, s)
    end
    vim.api.nvim_buf_set_lines(bufNew, 0, -1, false, lines)
  else
    utils.info("Unsupported language - " .. ft, "Generate Debug Profile")
  end
end

function M.toggle_human_mode()
  if vim.g.vimspector_enable_mappings == nil then
    vim.g.vimspector_enable_mappings = "HUMAN"
    utils.info("Enabled HUMAN mappings", "Debug")
  else
    vim.g.vimspector_enable_mappings = nil
    utils.info("Disabled HUMAN mappings", "Debug")
  end
end

function M.config()
    vim.cmd [[packadd! vimspector]] -- Load vimspector
    debuggers() -- Configure debuggers
    vim.g.vimspector_base_dir = '~/.config/vimspector-config'
end

return M

Installation Type

Plugin Manager (git clone)

Vimspector version

def0926

Debug Info

No response

Log file

No response

Vim version

NVIM v0.10.0-dev-2661+gc72d877c3
Build type: Debug
LuaJIT 2.1.1710088188

Python version

No response

Neovim diagnostics

No response

Operating System

No response

Declaration

puremourning commented 5 months ago

Sorry i can't debug a ton of obscure and incomprehensible neovim-only lua nonesense.

My best guess is that you installed it wrong, or didn't install it at all.

Follow the installation instructions and provide a minimal reproducible example and perhaps I can assist.

Assuming that this is not a bug bug an installation issue, therefore closing.

MikeLemo1 commented 5 months ago

Regarding the installation it uses the package manager Lazy and I've posted al the relevant config code that both installs vispector automatically and configs it. But it work's quite bugy if you didn't read it and won't let launch the debugger and start it without runninng :VimspectorInstall OR :VimspectorUpdate first...

puremourning commented 5 months ago

Take it up with the author of the package manager. That's nothing I can change. Your package manager, your choice. If you can demonstrate a problem using the supported installation methods in the readme, I'm all ears.