leoluz / nvim-dap-go

An extension for nvim-dap providing configurations for launching go debugger (delve) and debugging individual tests
MIT License
498 stars 78 forks source link

Getting an error every time I try to debug a test: Failed to launch: could not launch process: not an executable file #88

Closed kujtimiihoxha closed 6 months ago

kujtimiihoxha commented 6 months ago

I am using nvim-dap-go and neotest-golang ontop of astronvim. I think I am adding all the necessary configuration but for some reason it is not working I tried reading the dap logs but can't figure out what the issue is

[ DEBUG ] 2024-05-25T13:32:20Z+0200 ] ...oxha/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1165 ]    "Starting debug adapter server executable"  {
  args = { "dap", "-l", "127.0.0.1:49309" },
  command = "dlv",
  detached = true
}
[ DEBUG ] 2024-05-25T13:32:20Z+0200 ] ...oxha/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1295 ]    "Debug adapter server executable started, listening on 49309"
[ DEBUG ] 2024-05-25T13:32:20Z+0200 ] ...oxha/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1299 ]    "Connecting to debug adapter"   {
  executable = {
    args = { "dap", "-l", "127.0.0.1:49309" },
    command = "dlv",
    detached = true
  },
  options = {
    initialize_timeout_sec = 20
  },
  port = 49309,
  type = "server"
}
[ DEBUG ] 2024-05-25T13:32:20Z+0200 ] ...oxha/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    adapterID = "nvim-dap",
    clientId = "neovim",
    clientname = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_US.UTF-8",
    pathFormat = "path",
    supportsProgressReporting = true,
    supportsRunInTerminalRequest = true,
    supportsStartDebuggingRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 0,
  type = "request"
}
[ DEBUG ] 2024-05-25T13:32:20Z+0200 ] ...oxha/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 4   {
  body = {
    supportsClipboardContext = true,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDelayedStackTraceLoading = true,
    supportsDisassembleRequest = true,
    supportsEvaluateForHovers = true,
    supportsExceptionInfoRequest = true,
    supportsFunctionBreakpoints = true,
    supportsInstructionBreakpoints = true,
    supportsLogPoints = true,
    supportsSetVariable = true,
    supportsSteppingGranularity = true
  },
  command = "initialize",
  request_seq = 0,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-05-25T13:32:20Z+0200 ] ...oxha/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    args = { "-test.run", "^TestFileParser_FindGoFiles$" },
    cwd = "/Users/kujtimhoxha/go-services/gs/parser",
    mode = "test",
    name = "Neotest-golang",
    program = "/Users/kujtimhoxha/go-services/gs",
    request = "launch",
    type = "go"
  },
  command = "launch",
  seq = 1,
  type = "request"
}
[ DEBUG ] 2024-05-25T13:32:20Z+0200 ] ...oxha/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 4   {
  body = {
    error = {
      format = "Failed to launch: could not launch process: not an executable file",
      id = 3000,
      showUser = true
    }
  },
  command = "launch",
  message = "Failed to launch",
  request_seq = 1,
  seq = 0,
  success = false,
  type = "response"
}

nvim-dap config

return {

  "mfussenegger/nvim-dap",
  dependencies = {
    "mxsdev/nvim-dap-vscode-js",

    "leoluz/nvim-dap-go",
    -- build debugger from source
    {
      "microsoft/vscode-js-debug",
      version = "1.x",
      build = "npm i && npm run compile vsDebugServerBundle && mv dist out",
    },
  },
  config = function()
    require("dap-go").setup {}

    require("dap-vscode-js").setup {
      debugger_path = vim.fn.stdpath "data" .. "/lazy/vscode-js-debug",
      adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" },
    }

    for _, language in ipairs { "typescript", "javascript", "vue" } do
      require("dap").configurations[language] = {
        -- attach to a node process that has been started with
        -- `--inspect` for longrunning tasks or `--inspect-brk` for short tasks
        -- npm script -> `node --inspect-brk ./node_modules/.bin/vite dev`
        {
          -- use nvim-dap-vscode-js's pwa-node debug adapter
          type = "pwa-node",
          -- attach to an already running node process with --inspect flag
          -- default port: 9222
          request = "attach",
          -- allows us to pick the process using a picker
          processId = require("dap.utils").pick_process,
          -- name of the debug action you have to select for this config
          name = "Attach debugger to existing `node --inspect` process",
          -- for compiled languages like TypeScript or Svelte.js
          sourceMaps = true,
          -- resolve source maps in nested locations while ignoring node_modules
          resolveSourceMapLocations = {
            "${workspaceFolder}/**",
            "!**/node_modules/**",
          },
          -- path to src in vite based projects (and most other projects as well)
          cwd = "${workspaceFolder}/src",
          -- we don't want to debug code inside node_modules, so skip it!
          skipFiles = { "${workspaceFolder}/node_modules/**/*.js" },
        },
        {
          type = "pwa-chrome",
          name = "Launch Chrome to debug client",
          request = "launch",
          url = "http://localhost:5173",
          sourceMaps = true,
          protocol = "inspector",
          port = 9222,
          webRoot = "${workspaceFolder}/src",
          -- skip files from vite's hmr
          skipFiles = { "**/node_modules/**/*", "**/@vite/*", "**/src/client/*", "**/src/*" },
        },
        -- only if language is javascript, offer this debug action
        language == "javascript"
            and {
              -- use nvim-dap-vscode-js's pwa-node debug adapter
              type = "pwa-node",
              -- launch a new process to attach the debugger to
              request = "launch",
              -- name of the debug action you have to select for this config
              name = "Launch file in new node process",
              -- launch current file
              program = "${file}",
              cwd = "${workspaceFolder}",
            }
          or nil,
      }
    end
  end,
}

Neotest config

return {
  "nvim-neotest/neotest",
  dependencies = {
    "fredrikaverpil/neotest-golang", -- Installation
    "marilari88/neotest-vitest",
  },
  opts = function(_, opts)
    if not opts.adapters then opts.adapters = {} end
    local goConfig = { dap_go_enabled = true } -- Specify configuration
    table.insert(opts.adapters, require "neotest-vitest"(require("astrocore").plugin_opts "neotest-vitest"))
    table.insert(opts.adapters, require "neotest-golang"(goConfig))
  end,
}
kujtimiihoxha commented 6 months ago

Ok looks like the issue is not nvim-dap-go, I got it working standalone, I will move this issue to neotest-golang