nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.29k stars 114 forks source link

[BUG] subprocess fails on non-default environments #398

Closed przepompownia closed 5 months ago

przepompownia commented 5 months ago

NeoVim Version v0.10.0-dev-3003+ge0d92b9cc

Describe the bug If the main nvim process starts with non-default XDG_* and runtimepath directories, the child process seems to not respect those settings. In effect it, for example, cannot find neotest module.

To Reproduce The project https://github.com/przepompownia/neotest-phpunit-example (on 22a8004a3198a3f4db494f6fbda5752c80745fa3) maybe isn't minimal for this bug but simply shows what happens. From its directory run

make start

and look into .xdg/state/nvim/neotest.log. I see

ERROR | 2024-04-25T15:48:25Z+0200 | ...-strategy/plugins/neotest/lua/neotest/lib/subprocess.lua:76 | Failed to initialize child process Vim:Error invoking 'nvim_exec_lua' on channel 3:
Error executing lua: [string "<nvim>"]:1: module 'neotest' not found:
    no field package.preload['neotest']
    no file './neotest.lua'
    no file '/usr/share/luajit-2.1/neotest.lua'
    no file '/usr/local/share/lua/5.1/neotest.lua'
    no file '/usr/local/share/lua/5.1/neotest/init.lua'
    no file '/usr/share/lua/5.1/neotest.lua'
    no file '/usr/share/lua/5.1/neotest/init.lua'
    no file './neotest.so'
    no file '/usr/local/lib/lua/5.1/neotest.so'
    no file '/usr/lib/x86_64-linux-gnu/lua/5.1/neotest.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'require'
    [string "<nvim>"]:1: in main chunk
stack traceback:
    [C]: in function 'rpcrequest'
    ...-strategy/plugins/neotest/lua/neotest/lib/subprocess.lua:61: in function <...-strategy/plugins/neotest/lua/neotest/lib/subprocess.lua:54>
    [C]: in function 'xpcall'
    ...-strategy/plugins/neotest/lua/neotest/lib/subprocess.lua:54: in function 'init'
    ...dap-strategy/plugins/neotest/lua/neotest/client/init.lua:374: in function '_start'
    ...dap-strategy/plugins/neotest/lua/neotest/client/init.lua:188: in function '_ensure_started'
    ...dap-strategy/plugins/neotest/lua/neotest/client/init.lua:173: in function 'get_adapters'
    ...lugins/neotest/lua/neotest/consumers/summary/summary.lua:114: in function <...lugins/neotest/lua/neotest/consumers/summary/summary.lua:113>

init.lua provided there contains all relevant things (XDG_* and runtimepath).

On the other side I don't see any practical effect of this error.

przepompownia commented 5 months ago

I updated https://github.com/przepompownia/neotest-phpunit-example to behave closer to standard and no longer get such error. Not sure how much fixing this error is worth effort so I close this PR at the moment.