Open Malefaro opened 2 years ago
I pinned to v1.35.0 and this wasn't happening there, but I was getting segfaults on v1.37.4 so it's likely between those two versions. I tested with latest plenary and neotest-python
I need something to reproduce, I haven't experienced this. Please provide the logs and a minimal init file.
Initial guess would be something with the neovim subprocess since that was introduced in 1.37.0. If you want to test locally you can comment out this line https://github.com/nvim-neotest/neotest/blob/63d180622545316922ab94215a3a0049d5458621/lua/neotest/client/init.lua#L336 to avoid starting the subprocess
neotest.log clear log after crash
I need something to reproduce, I haven't experienced this. Please provide the logs and a minimal init file.
Initial guess would be something with the neovim subprocess since that was introduced in 1.37.0. If you want to test locally you can comment out this line
to avoid starting the subprocess
still crashes after comment out this line
I'm afraid the logs don't tell me enough on their own, I'll still need a init.lua
vim.cmd [[packadd packer.nvim]]
vim.g.mapleader = ","
vim.opt.termencoding = 'UTF-8'
vim.opt.encoding = 'UTF-8'
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.tabstop = 4
vim.opt.expandtab = true
vim.opt.autoread = true
-- line length
vim.opt.colorcolumn = "100"
-- for gitgutter
vim.opt.updatetime = 100
vim.opt.mouse = 'a'
vim.opt.mousemodel = 'popup'
vim.opt.cursorline = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.list = true
map = vim.api.nvim_set_keymap
opts = { noremap = true, silent = true }
for _, mode in pairs({ 'n', 'v' }) do
map(mode, 'J', '5j', {})
map(mode, 'K', '5k', {})
map(mode, 'L', '3l', {})
map(mode, 'H', '3h', {})
end
map('n', '<C-s>', '<C-[>', {})
for _, mode in pairs({ 'i', 'v', 'c', 't', 'o', 's', 'x' }) do
map(mode, '<C-s>', '<C-[>', { noremap = true })
end
map('n', '<C-s>', ':w<CR>', opts)
map('n', 'dq', ':q<CR>', {})
map('t', '<C-j>', '<Down>', {})
map('t', '<C-k>', '<Up>', {})
vim.cmd [[
filetype plugin on
set number
set backspace=2
set clipboard+=unnamedplus
inoremap <expr><C-j> pumvisible() ? "\<Down>" : "\<C-n>"
inoremap <expr><C-k> pumvisible() ? "\<Up>" : "\<C-p>"
" exist to normal mode in terminal
tnoremap <Esc> <C-\><C-n>
nmap <silent> <ESC> :nohlsearch<CR>
au BufWritePost *.py :silent !black %
set completeopt+=noinsert
]]
map = vim.api.nvim_set_keymap
opts = { noremap = true, silent = true }
require("packer").startup(function(use)
use 'wbthomason/packer.nvim'
use { 'nvim-neotest/neotest', requires = "antoinemadec/FixCursorHold.nvim" }
use 'nvim-neotest/neotest-go'
use 'nvim-neotest/neotest-python'
use 'nvim-neotest/neotest-plenary'
use 'vim-test/vim-test'
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate',
config = function()
local ts = require('nvim-treesitter.configs')
ts.setup {
ensure_installed = { "python", "go", "rust", "lua" },
highlight = {
enable = true,
}
}
end
}
use 'nvim-lua/plenary.nvim'
end)
vim.api.nvim_command("PackerCompile")
require('neotest').setup({
floating = {
border = "rounded",
max_height = 0.85,
max_width = 0.85,
options = {}
},
log_level = 1,
adapters = {
require('neotest-python')({
dap = { justMyCode = false },
args = { "--dc=Local", "--ds=gateway.settings_local", "--color=yes", "--reuse-db" }
}),
require('neotest-go')({
args = { "-count=1", "-timeout=60s" }
}),
require('neotest-plenary'),
},
})
local map = vim.api.nvim_set_keymap
map('n', '<leader>tn', '<cmd>lua require("neotest").run.run()<cr>', {})
map('n', '<leader>td', '<cmd>lua require("neotest").run.run({strategy="dap"})<cr>', {})
map('n', '<leader>ts', '<cmd>lua require("neotest").summary.toggle()<cr>', {})
map('n', '<leader>to', '<cmd>lua require("neotest").output.open({enter=true})<cr>', {})
map('n', '<leader>ta', '<cmd>lua require("neotest").run.attach()<cr>', {})
map('n', '<leader>tf', '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))<cr>', {})
map('n', '<leader>te', '<cmd>lua require("neotest").run.stop()<cr>', {})
Crashes happens since 1.37.2 (on 1.37.1 everything is fine)
Thanks for that, but I still can't reproduce.
That's great that it's narrowed down to 1.37.2. The main change of that version was the refactoring of the file finding logic which would make sense as a problematic area as there are a lot of system calls. There could be a platform specific problem or it could be that it's reading too many files.
Could you experiment with different size repos? I've tested with fairly large repos myself and not had issues but every system is different. I've added a new log line to show which directories are being scanned which will hopefully help pinpoint the issue
With small size repo everything works fine with python project it scans 200+ dirs with go project it scans 600+ dirs (but it scans vendor dir with library code that does not contains tests) Intresting part: there is always different number of scanned dirs. (I clear log before each run). Even if its not crashed and output "no tests found" its does not scan all dirs. By the way. If nvim not crashed and output "no tests found", after save it finds tests but only in current file
with go project it scans 600+ dirs (but it scans vendor dir with library code that does not contains tests)
You can filter directories that will be scanned to avoid doing this. If it's a common thing in go to have that then maybe the adapter should do that by default, so would be worth opening an issue.
By the way. If nvim not crashed and output "no tests found", after save it finds tests but only in current file
That makes sense, it's discovered the file by matching the buffer rather than through the file system so it circumvents this issue.
If it doesn't crash, do you see any error in the logs saying Couldn't find positions in path ...
?
Also does tweaking the max entries value here https://github.com/nvim-neotest/neotest/blob/9a950675a2284558c56aea7ba9522ae642495e3d/lua/neotest/lib/file/find.lua#L24 have any effect? Set it to something like 10
If we can't figure this out, I may put back the old discovery code that worked for you previously and allow using it under an option in the config.
I am also experiencing this issue. I have been using the latest versions for a while with Arch Linux but hit this one when I switched to using NixOS on the same machine.
Version 1.37.1
works fine and 1.37.2
crashes fairly reliably or produces "No tests found".
Happy to provide logs etc but not sure how to produce them.
What neovim version are you using on NixOS?
In your config set log_level = vim.log.levels.DEBUG
. The log file can be found at :echo stdpath("log")
. Wipe any existing logs before reproducing and then paste the file here :smile:
Same problem here. Not in NixOS. It just crashes nvim whenever I run any neotest command.
ERROR | 2023-03-22T21:26:15Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:30 | Child process is waiting for input at startup. Aborting.
ERROR | 2023-03-22T21:46:32Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:30 | Child process is waiting for input at startup. Aborting.
DEBUG | 2023-03-22T21:55:52Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:306 | User config {
adapters = { {
_generate_position_id = <function 1>,
build_spec = <function 2>,
discover_positions = <function 3>,
is_test_file = <function 4>,
name = "neotest-go",
results = <function 5>,
root = <function 6>,
<metatable> = {
__call = <function 7>
}
} },
benchmark = {
enabled = true
},
consumers = {},
default_strategy = "integrated",
diagnostic = {
enabled = true,
severity = 1
},
discovery = {
concurrent = 14,
enabled = true
},
floating = {
border = "rounded",
max_height = 0.6,
max_width = 0.6,
options = {}
},
highlights = {
adapter_name = "NeotestAdapterName",
border = "NeotestBorder",
dir = "NeotestDir",
expand_marker = "NeotestExpandMarker",
failed = "NeotestFailed",
file = "NeotestFile",
focused = "NeotestFocused",
indent = "NeotestIndent",
marked = "NeotestMarked",
namespace = "NeotestNamespace",
passed = "NeotestPassed",
running = "NeotestRunning",
select_win = "NeotestWinSelect",
skipped = "NeotestSkipped",
target = "NeotestTarget",
test = "NeotestTest",
unknown = "NeotestUnknown"
},
icons = {
child_indent = "│",
child_prefix = "├",
collapsed = "─",
expanded = "╮",
failed = "",
final_child_indent = " ",
final_child_prefix = "╰",
non_collapsible = "─",
passed = "",
running = "",
running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
skipped = "",
unknown = ""
},
jump = {
enabled = true
},
log_level = 1,
output = {
enabled = true,
open_on_run = "short"
},
output_panel = {
enabled = true,
open = "botright split | resize 15"
},
projects = {
<metatable> = {
__index = <function 8>
}
},
quickfix = {
enabled = true,
open = true
},
run = {
enabled = true
},
running = {
concurrent = true
},
state = {
enabled = true
},
status = {
enabled = true,
signs = true,
virtual_text = false
},
strategies = {
integrated = {
height = 40,
width = 120
}
},
summary = {
animated = true,
enabled = true,
expand_errors = true,
follow = true,
mappings = {
attach = "a",
clear_marked = "M",
clear_target = "T",
debug = "d",
debug_marked = "D",
expand = { "<CR>", "<2-LeftMouse>" },
expand_all = "e",
jumpto = "i",
mark = "m",
next_failed = "J",
output = "o",
prev_failed = "K",
run = "r",
run_marked = "R",
short = "O",
stop = "u",
target = "t"
},
open = "botright vsplit | vertical resize 50"
}
}
INFO | 2023-03-22T21:56:09Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:305 | Configuration complete
DEBUG | 2023-03-22T21:56:09Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:306 | User config {
adapters = { {
_generate_position_id = <function 1>,
build_spec = <function 2>,
discover_positions = <function 3>,
is_test_file = <function 4>,
name = "neotest-go",
results = <function 5>,
root = <function 6>,
<metatable> = {
__call = <function 7>
}
} },
benchmark = {
enabled = true
},
consumers = {},
default_strategy = "integrated",
diagnostic = {
enabled = true,
severity = 1
},
discovery = {
concurrent = 14,
enabled = true
},
floating = {
border = "rounded",
max_height = 0.6,
max_width = 0.6,
options = {}
},
highlights = {
adapter_name = "NeotestAdapterName",
border = "NeotestBorder",
dir = "NeotestDir",
expand_marker = "NeotestExpandMarker",
failed = "NeotestFailed",
file = "NeotestFile",
focused = "NeotestFocused",
indent = "NeotestIndent",
marked = "NeotestMarked",
namespace = "NeotestNamespace",
passed = "NeotestPassed",
running = "NeotestRunning",
select_win = "NeotestWinSelect",
skipped = "NeotestSkipped",
target = "NeotestTarget",
test = "NeotestTest",
unknown = "NeotestUnknown"
},
icons = {
child_indent = "│",
child_prefix = "├",
collapsed = "─",
expanded = "╮",
failed = "",
final_child_indent = " ",
final_child_prefix = "╰",
non_collapsible = "─",
passed = "",
running = "",
running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
skipped = "",
unknown = ""
},
jump = {
enabled = true
},
log_level = 1,
output = {
enabled = true,
open_on_run = "short"
},
output_panel = {
enabled = true,
open = "botright split | resize 15"
},
projects = {
<metatable> = {
__index = <function 8>
}
},
quickfix = {
enabled = true,
open = true
},
run = {
enabled = true
},
running = {
concurrent = true
},
state = {
enabled = true
},
status = {
enabled = true,
signs = true,
virtual_text = false
},
strategies = {
integrated = {
height = 40,
width = 120
}
},
summary = {
animated = true,
enabled = true,
expand_errors = true,
follow = true,
mappings = {
attach = "a",
clear_marked = "M",
clear_target = "T",
debug = "d",
debug_marked = "D",
expand = { "<CR>", "<2-LeftMouse>" },
expand_all = "e",
jumpto = "i",
mark = "m",
next_failed = "J",
output = "o",
prev_failed = "K",
run = "r",
run_marked = "R",
short = "O",
stop = "u",
target = "t"
},
open = "botright vsplit | vertical resize 50"
}
}
INFO | 2023-03-22T21:56:31Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:32 | Starting child process
INFO | 2023-03-22T21:56:31Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:35 | Parent address: localhost:58983
INFO | 2023-03-22T21:56:31Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:41 | Starting child process with command: /usr/local/Cellar/neovim/0.8.3/bin/nvim --embed --headless
ERROR | 2023-03-22T21:56:32Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:56 | Child process is waiting for input at startup. Aborting.
INFO | 2023-03-22T21:56:37Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:305 | Configuration complete
DEBUG | 2023-03-22T21:56:37Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:306 | User config {
adapters = { {
_generate_position_id = <function 1>,
build_spec = <function 2>,
discover_positions = <function 3>,
is_test_file = <function 4>,
name = "neotest-go",
results = <function 5>,
root = <function 6>,
<metatable> = {
__call = <function 7>
}
} },
benchmark = {
enabled = true
},
consumers = {},
default_strategy = "integrated",
diagnostic = {
enabled = true,
severity = 1
},
discovery = {
concurrent = 14,
enabled = true
},
floating = {
border = "rounded",
max_height = 0.6,
max_width = 0.6,
options = {}
},
highlights = {
adapter_name = "NeotestAdapterName",
border = "NeotestBorder",
dir = "NeotestDir",
expand_marker = "NeotestExpandMarker",
failed = "NeotestFailed",
file = "NeotestFile",
focused = "NeotestFocused",
indent = "NeotestIndent",
marked = "NeotestMarked",
namespace = "NeotestNamespace",
passed = "NeotestPassed",
running = "NeotestRunning",
select_win = "NeotestWinSelect",
skipped = "NeotestSkipped",
target = "NeotestTarget",
test = "NeotestTest",
unknown = "NeotestUnknown"
},
icons = {
child_indent = "│",
child_prefix = "├",
collapsed = "─",
expanded = "╮",
failed = "",
final_child_indent = " ",
final_child_prefix = "╰",
non_collapsible = "─",
passed = "",
running = "",
running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
skipped = "",
unknown = ""
},
jump = {
enabled = true
},
log_level = 1,
output = {
enabled = true,
open_on_run = "short"
},
output_panel = {
enabled = true,
open = "botright split | resize 15"
},
projects = {
<metatable> = {
__index = <function 8>
}
},
quickfix = {
enabled = true,
open = true
},
run = {
enabled = true
},
running = {
concurrent = true
},
state = {
enabled = true
},
status = {
enabled = true,
signs = true,
virtual_text = false
},
strategies = {
integrated = {
height = 40,
width = 120
}
},
summary = {
animated = true,
enabled = true,
expand_errors = true,
follow = true,
mappings = {
attach = "a",
clear_marked = "M",
clear_target = "T",
debug = "d",
debug_marked = "D",
expand = { "<CR>", "<2-LeftMouse>" },
expand_all = "e",
jumpto = "i",
mark = "m",
next_failed = "J",
output = "o",
prev_failed = "K",
run = "r",
run_marked = "R",
short = "O",
stop = "u",
target = "t"
},
open = "botright vsplit | vertical resize 50"
}
}
It just hangs so don't know if its the logs from the hanguing.
Happy to provide any other logs that are needed.
I did some experimenting and found that this problem only seems to occur for me on larger code-bases.
List of source files.
❯ fd | wc -l
252
List of all files including those in .gitignore
(tmp
, node_modules
etc)
❯ fd --no-ignore | wc -l
12128
❯ fd | wc -l
8260
❯ fd --no-ignore | wc -l
100402
One thing I notice in the logs is that neotest is scanning all the non source code files in .gitignore
.
DEBUG | 2023-03-24T11:44:08Z+1100 | .../pack/packer/start/neotest/lua/neotest/lib/file/find.lua:30 | Scanning directory: tmp
DEBUG | 2023-03-24T11:44:08Z+1100 | .../pack/packer/start/neotest/lua/neotest/lib/file/find.lua:30 | Scanning directory: node_modules
Those directories contain an enourmous amount of junk that might be clogging neotest up?
✦ ❯ fd --no-ignore . node_modules/ | wc -l
26996
✦ ❯ fd --no-ignore . tmp/ | wc -l
65115
I wonder if there might be something in adding an ability to either ignore directories or respect a .gitignore
file? Perhaps this already exists?
What neovim version are you using on NixOS?
❯ nvim --version
NVIM v0.9.0-dev-c6f8af3
Build type: Release
LuaJIT 2.1.0-beta3
Currently using nightly but had the same issue on 0.8.1
.
Ah yes @compactcode it looks like your adapters don't define a suitable filter_dir
function
https://github.com/nvim-neotest/neotest/blob/bbbfa55d850f1aaa6707ea85fb5230ac866459c6/lua/neotest/adapters/interface.lua#L14-L20
I would raise the issue for them so all users benefit but you can provide a custom one in the neotest setup
neotest.setup({
discovery = {
filter_dir = function(name, rel_path, root)
return name ~= "node_modules"
end,
},
...
@Numbers88s Are you also seeing this on large projects? I've tested with 100000 files myself and still had no issue so still not sure what the exact cause is
I tried filter_dir
which did remove the node_modules scan. Unfortunately the issue still persists.
Can you provide logs?
I also encountered a similar segmentation fault on NixOS. When I "Run the nearest test", there is no problem, but when I "Debug the nearest test", a segmentation fault occurs. The version of nvim is 0.8.1.
I am also having this issue. It seems that this is related to the subprocess that is initialized (with nvim --headless --embed
) is stuck in blocking mode (waiting for input). The main process then hangs because
https://github.com/nvim-neotest/neotest/blob/80f9c963019dc72d46574ff0ccb9a428f232afc5/lua/neotest/lib/subprocess.lua#L55-L58 logs an error but does not throw an error up the call stack. As far as I understand this then blocks at the next RPC call.
I modified the file throwing a random error after the error log, which seems to work as a workaround, but means I am not delegating stuff to the child process. I have no idea why the child nvim process is stuck in blocking mode though ...
Thanks for pointing out that it wasn't aborting, just logging that it was :facepalm: Added a fix for that at least
I have no idea why the child nvim process is stuck in blocking mode though ...
If you run nvim --embed --headless
, do you see anything printed?
f you run
nvim --embed --headless
, do you see anything printed?
Nope I do not. Should I? I also tried running with nvim --embed --headless -u NONE
to ensure it is not linked to my configurasion, but it also does not print anything.
Just as an additional data point, I see the crash for the dotnet plug on a small local repo - ~50 source files. It happens every time for me.
The error that shows up in my main log is:
ERR 2023-07-15T15:54:50.045 nvim.15864.0 pty_process_spawn:133: pty_process_spawn(C:/Program\ Files/Git/usr/bin/bash.exe): os_conpty_spawn failed: error code: 2
NeoVim Version NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3
On macos monterey 12.4 m1 pro
Describe the bug When opening nvim and trying to call a summary or run a nearest test, nvim crashes with a segfault error. This happens inconstantly, but even if nvim doesn't crash it displays "no tests found". However if summary opens with "no tests found", after saving, the tests are found and run without errors. This happends in neotest-go and neotest-python.
The issue was in nvim v0.7 too. Plugins have been updated. Crashes occur only in this scenario.
Logs Nothing special. Run with
log_level=1
. No ERROR messages.Additional context Backtrace