Skip to content

bug: wrong paths with local-lua-debugger-vscode #46

@polirritmico

Description

@polirritmico

Did you check docs and existing issues?

  • I have read the documentation
  • I have searched the existing issues
  • I have searched the existing issues of plugins related to this issue (if relevant)
  • I have tried setting log_level to vim.log.levels.debug in neotest.setup and examined the logs.

Neovim version (nvim -v)

NVIM v0.10.3 Build type: Release LuaJIT 2.1.1716656478

Operating system/version

Gentoo Linux 2.17

Describe the bug

Hi, I hope everything is going well. I love seeing the progress this project has made so far with the latest versions.

These days I've been trying the debugging capabilities with local-lua-debugger-vscode, and it has worked well except for some problems with the imports.

For example, I have this structure:

$ tree case
case/
├── lua
│   └── foo
│       └── init.lua
├── Makefile
└── tests
    ├── busted.lua
    ├── foo_spec.lua
    └── helpers.lua

If I require the helpers module from the foo_spec test file, then depending if I'm running a normal test through neotest or a debug test through dap, I have to adjust the require path:

-- in foo_spec.lua
local foo = require("foo")
local helpers = require("tests.helpers") -- this fail

The above code would work fine using :lua require("neotest").run.run() or nvim -l tests/busted.lua tests from the command line, but it would fail using :lua require("neotest").run.run(strategy="dap").

It complains that it couldn't find the tests.helpers module with this error:

Error → /home/<user>/repro/case/tests/foo_spec.lua @ 2
local-lua-debugger-vscode should load helpers in the correct path
/home/<user>/repro/case/tests/foo_spec.lua:4: module 'tests.helpers' not found:
        no field package.preload['tests.helpers']
cache_loader: module tests.helpers not found
cache_loader_lib: module tests.helpers not found
        no file './src/tests/helpers.lua'
        no file './src/tests/helpers/tests/helpers.lua'
        no file './src/tests/helpers/init.lua'
        no file 'lua/tests/helpers.lua'
        no file 'lua/tests/helpers/init.lua'
        no file '/home/<user>/tmp/local-lua-debugger-vscode//debugger/tests/helpers.lua'
        no file '/home/<user>/repro/case/.tests//data/nvim/lazy-rocks/busted/share/lua/5.1/tests/helpers.lua'
        no file '/home/<user>/repro/case/.tests//data/nvim/lazy-rocks/busted/share/lua/5.1/tests/helpers/init.lua'
        no file '/home/<user>/repro/case/tests/tests/helpers.lua'
        no file './csrc/tests/helpers.so'
        no file './csrc/tests/helpers/tests/helpers.so'
        no file '/home/<user>/repro/case/.tests//data/nvim/lazy-rocks/busted/lib/lua/5.1/tests/helpers.so'
        no file '/home/<user>/repro/case/.tests//data/nvim/lazy-rocks/busted/lib64/lua/5.1/tests/helpers.so'
        no file './csrc/tests.so'
        no file './csrc/tests/tests.so'
        no file '/home/<user>/repro/case/.tests//data/nvim/lazy-rocks/busted/lib/lua/5.1/tests.so'
        no file '/home/<user>/repro/case/.tests//data/nvim/lazy-rocks/busted/lib64/lua/5.1/tests.so'

I don't completely rule out that it may be an issue in my config, but since the debug session itself is working fine, and the require calls are working outside the dap neotest session, maybe is something related to a path missing or not created properly. For example, this path seems very strange:

no file '/home/<user>/repro/case/tests/tests/helpers.lua'

Expected Behavior

require("tests.helpers") should work fine when using the dap session through neotest-busted.

Output of :checkhealth neotest-busted if relevant

No response

neotest log output if relevant

No response

Steps To Reproduce

Replicate the issue involve a lot of steps to fully set the environment, so I've made a repro repository here. Since local-lua-debugger-vscode is needed for all this, I've use a Makefile with git clone and npm for the build:

  1. git clone https://github.com/polirritmico/busted-repro.git
  2. cd busted-repro
  3. nvim -u repro-demo.lua
  4. Follow the message instructions:
    1. Clone and build the local-lua-debugger-vscode in the expected path by the config
    2. Run the lazy/busted bootstrap
    3. Open the case and set the breakpoints
    4. Run the neotest dap session

I hope that the automation works, but in any case, I've also added a standard repro.lua file (try with nvim -u repro.lua). Beyond that, with the case folder itself it should be relatively straight forward to reproduce the issue after running the busted/lazy bootstrap.

Thanks!

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions