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

Error: The selected configuration references adapter nil, but dap.adapters.nil is undefined #37

Open
frdrkolsson opened this issue Mar 22, 2023 · 3 comments

Comments

@frdrkolsson
Copy link

frdrkolsson commented Mar 22, 2023

Hi,

Just set this up and have been debugging it for a couple of hours now to no avail.

Every time I run :lua require('dap').continue with the config down below, I get the message in the title.

The selected configuration references adapter `nil`, but dap.adapters.nil is undefined

The configuration seems to load, but the adapter does not seem to be registered.

The following is my config. Tried with a different couple of setups just to get this started, but none seems to cooperate. Have tried on both .js and .tsx files.

local dap = require('dap')

require("dap-vscode-js").setup({
  debugger_path = os.getenv('HOME') .. '/Code/vscode-js-debug',
  node_path = os.getenv('HOME') .. '.asdf/shims/node',
  -- debugger_cmd = { "js-debug-adapter" },                                                                         -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
  adapters = { 'pwa-node' }
})

local js_languages = { "typescript", "javascript", "typescriptreact" }
for _, language in ipairs(js_languages) do
  dap.configurations[language] = {
    {
      {
        type = "pwa-node",
        request = "launch",
        name = "Launch Test Program (pwa-node with vitest)",
        cwd = "${workspaceFolder}",
        program = "${workspaceFolder}/node_modules/vitest/vitest.mjs",
        args = { "--threads", "false", },
        autoAttachChildProcesses = false,
        trace = true,
        console = "integratedTerminal",
        sourceMaps = true,
        smartStep = true,
      },
    }
  }
end

Does anyone see something out of place, or know why none of the adapters from this plugin seems to be setup?
My neovim config is available here if anyone is interested into looking deeper into the problem.

@jorgerojas26
Copy link

I'm also having this issue

@amircodota
Copy link

Had the same issue.

The problem is that the launch configuration is incorrectly typed.
I think we all copied it from some blog post or something, though I am not sure which one.

In any case, the bad configuration is this

dap.configurations[language] = {
    {
      {
        type = "pwa-node",
        request = "launch",
        name = "Launch Test Program (pwa-node with vitest)",
        cwd = "${workspaceFolder}",
        program = "${workspaceFolder}/node_modules/vitest/vitest.mjs",
        args = { "--threads", "false", },
        autoAttachChildProcesses = false,
        trace = true,
        console = "integratedTerminal",
        sourceMaps = true,
        smartStep = true,
      },
    }
  }

Thats' one curly too much :-)

The correct one is this

dap.configurations[language] = {
      {
        type = "pwa-node",
        request = "launch",
        name = "Launch Test Program (pwa-node with vitest)",
        cwd = "${workspaceFolder}",
        program = "${workspaceFolder}/node_modules/vitest/vitest.mjs",
        args = { "--threads", "false", },
        autoAttachChildProcesses = false,
        trace = true,
        console = "integratedTerminal",
        sourceMaps = true,
        smartStep = true,
      },
  }

@zettlrobert
Copy link

What works for me is:

      for _, js_filetype in ipairs(js_based_filetypes) do
        dap.configurations[js_filetype] = {
          -- Debug single Vitest
          {
            type = "pwa-node",
            request = "launch",
            name = "Vitest File (pwa-node)",
            autoAttachChildProcesses = true,
            runtimeExecutable = "node",
            runtimeArgs = {
              "${workspaceFolder}/node_modules/vitest/vitest.mjs",
              "--inspect-brk",
              "${file}",
              "--poolOptions.threads.singleThread",
              "true",
            },
            rootPath = "${workspaceFolder}",
            cwd = "${workspaceFolder}",
            console = "integratedTerminal",
            skipFiles = { "<node_internals>/**", "**/node_modules/**" },
          }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants