mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception using `pick_process`

1dr0z opened this issue · comments

commented

Debug adapter definition and debug configuration

dap.configurations.javascript = {
  {
    name = 'Attach to process',
    type = 'node2',
    request = 'attach',
    restart = true,
    processId = require'dap.utils'.pick_process,
  },
}

Debug adapter version

Commit 76e2e5f

Steps to Reproduce

Run a configuration using require'dap.utils'.pick_process

Expected Result

Prompt to pick running process

Actual Result

I'm seeing the following error using pick_process on macOS:

E5108: Error executing lua ...hare/nvim/site/pack/packer/start/nvim-dap/lua/dap/ui.lua:41: bad argument #2 to 'label_fn' (number expected, got nil)
stack traceback:
        [C]: in function 'label_fn'
        ...hare/nvim/site/pack/packer/start/nvim-dap/lua/dap/ui.lua:41: in function 'pick_one_sync'
        ...e/nvim/site/pack/packer/start/nvim-dap/lua/dap/utils.lua:79: in function 'option'
        ...l/share/nvim/site/pack/packer/start/nvim-dap/lua/dap.lua:156: in function <...l/share/nvim/site/pack/packer/start/nvim-dap/lua/dap.lua:154>
        vim/shared.lua: in function 'tbl_map'
        ...l/share/nvim/site/pack/packer/start/nvim-dap/lua/dap.lua:278: in function 'run'
        ...l/share/nvim/site/pack/packer/start/nvim-dap/lua/dap.lua:248: in function 'cb'
        ...hare/nvim/site/pack/packer/start/nvim-dap/lua/dap/ui.lua:31: in function 'pick_if_many'
        ...l/share/nvim/site/pack/packer/start/nvim-dap/lua/dap.lua:242: in function 'select_config_and_run'
        ...l/share/nvim/site/pack/packer/start/nvim-dap/lua/dap.lua:591: in function 'continue'
        [string ":lua"]:1: in main chunk

The check for pid ~= 'PID' seems to have been removed in #556. Unfortunately the command ps ah still contains headers on macOS. The man page for ps says:

     -h      Repeat the information header as often as necessary to guarantee one
             header per page of information.

The output of ps ah on macOS looks like this:

  PID   TT  STAT      TIME COMMAND
34756 s000  Ss+    0:00.72 -zsh
34171 s001  S+     0:00.31 node ./node_modules/.bin/ts-node-dev --exit-child --inspect --transpile-only index.ts
...

  PID   TT  STAT      TIME COMMAND
 4324 s010  S+     0:00.29 node /opt/homebrew/bin/typescript-language-server --stdio
...

Pinning nvim-dap to the commit prior to #556 (208c80e) fixes the issue.

Thanks for the report and sorry for the regression. Could you try #583 ?

commented

@mfussenegger That fixes it, thank you!