nvim-neotest / neotest

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

`Error executing luv callback` with message `bad argument #1 to 'func'`. neotest throws this error with lunarvim config. #80

Closed PedroVSCoimbra closed 2 years ago

PedroVSCoimbra commented 2 years ago

Helllo,

I've been trying to use neotest with Lunarvim, but is showing this error message every time. Apart from this error message the plugin seems to work just fine, it shwos the test results on the screen and on the side bar. If possible I could just silence this message.

Error executing luv callback:
...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with th
is message: ...vim/site/pack/packer/start/neotest/lua/neotest/async.lua:28: bad argument #1 to 'func' (table expected, got nil)
stack traceback:
        [C]: in function 'error'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: in function 'callback_or_next'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:40: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:39>
        [C]: in function 'matchlist'
        ...pack/packer/start/lualine.nvim/lua/lualine/component.lua:78: in function 'apply_padding'
        ...pack/packer/start/lualine.nvim/lua/lualine/component.lua:242: in function 'draw'
        .../packer/start/lualine.nvim/lua/lualine/utils/section.lua:26: in function 'draw_section'
        ...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:152: in function <...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:143>
        [C]: in function 'pcall'
        ...ck/packer/start/lualine.nvim/lua/lualine/utils/utils.lua:158: in function 'statusline'
        ...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:302: in function <...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:287>

Press ENTER or type command to continue

Error executing luv callback:
...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with th
is message: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: .../packer/start/neotest-python/lua/neotest-python/init.lua:132: bad argument #1
 to 'stream_data' (table expected, got nil)
stack traceback:
        [C]: in function 'error'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: in function 'callback_or_next'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:40: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:39>
Press ENTER or type command to continue
rcarriga commented 2 years ago

I need some info about your setup. What OS? What adapters? What NeoVim version?

Can you reproduce with the following init file? nvim --clean -u minimal.lua

You'll have to add the adapter your using

-- ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))
vim.opt.termguicolors = true

-- append test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))

-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
  vim.cmd("packadd packer.nvim")
  install_plugins = true
end

local packer = require("packer")

packer.init({
  package_root = test_dir .. "/pack",
  compile_path = test_dir .. "/plugin/packer_compiled.lua",
})

packer.startup(function(use)
  -- Packer can manage itself
  use("wbthomason/packer.nvim")

  use("vim-test/vim-test")
  use({
    "nvim-neotest/neotest",
    requires = {
      "nvim-lua/plenary.nvim",
      "nvim-treesitter/nvim-treesitter",
      "antoinemadec/FixCursorHold.nvim",
    },
    config = function()
      require("neotest").setup({
        adapters = {
          ...
        },
      })
    end,
  })

  if install_plugins then
    packer.sync()
  end
end)

vim.cmd([[
command! NeotestSummary lua require("neotest").summary.toggle()
command! NeotestFile lua require("neotest").run.run(vim.fn.expand("%"))
command! Neotest lua require("neotest").run.run(vim.fn.getcwd())
command! NeotestNearest lua require("neotest").run.run()
command! NeotestDebug lua require("neotest").run.run({ strategy = "dap" })
command! NeotestAttach lua require("neotest").run.attach()
]])
joshbode commented 2 years ago

I'm seeing the same problem when using the neotest-python adapter, and it appears to be related to recent changes in nvim-neotest/neotest-python@aaf8310. If I revert to nvim-neotest/neotest-python@023b7bd the error message does not present.

PedroVSCoimbra commented 2 years ago

I'm seeing the same problem when using the neotest-python adapter, and it appears to be related to recent changes in nvim-neotest/neotest-python@aaf8310. If I revert to nvim-neotest/neotest-python@023b7bd the error message does not present.

Hello, this does fix the problem. Thank you. Sorry for the lack of information, but I use the neotest-python, neovim version 0.7.2 on arch linux.

PedroVSCoimbra commented 2 years ago

Just a simple question. How do I navigate the error log? Is it possible?

joshbode commented 2 years ago

@PedroVSCoimbra do you mean something like :messages?

rcarriga commented 2 years ago

Can you please check if the minimal init.lua has the same issue for you? I need to know it's actually an issue with neotest before trying to debug this.

It seems like this is a lualine error and causing failures in neotest throught plenary's async library. This is the actual error being thrown:

 [C]: in function 'error'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: in function 'callback_or_next'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:40: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:39>
        [C]: in function 'matchlist'
        ...pack/packer/start/lualine.nvim/lua/lualine/component.lua:78: in function 'apply_padding'
        ...pack/packer/start/lualine.nvim/lua/lualine/component.lua:242: in function 'draw'
        .../packer/start/lualine.nvim/lua/lualine/utils/section.lua:26: in function 'draw_section'
        ...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:152: in function <...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:143>
        [C]: in function 'pcall'
        ...ck/packer/start/lualine.nvim/lua/lualine/utils/utils.lua:158: in function 'statusline'
        ...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:302: in function <...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:287>

This error is because of some poor handling in plenary's async lib (nothing to do with neotest AFAICT)

Error executing luv callback:
...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with th
is message: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: .../packer/start/neotest-python/lua/neotest-python/init.lua:132: bad argument #1
 to 'stream_data' (table expected, got nil)
PedroVSCoimbra commented 2 years ago

@PedroVSCoimbra do you mean something like :messages?

Yeah, could be something like that.

Do you use telescope right? It has a way to scroll the file with while search for something. The question is more of something like that. In your plugin it pops a floating window the idea would be to enter that buffer and navigate in it.

PedroVSCoimbra commented 2 years ago

Can you please check if the minimal init.lua has the same issue for you? I need to know it's actually an issue with neotest before trying to debug this.

It seems like this is a lualine error and causing failures in neotest throught plenary's async library. This is the actual error being thrown:

 [C]: in function 'error'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: in function 'callback_or_next'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:40: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:39>
        [C]: in function 'matchlist'
        ...pack/packer/start/lualine.nvim/lua/lualine/component.lua:78: in function 'apply_padding'
        ...pack/packer/start/lualine.nvim/lua/lualine/component.lua:242: in function 'draw'
        .../packer/start/lualine.nvim/lua/lualine/utils/section.lua:26: in function 'draw_section'
        ...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:152: in function <...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:143>
        [C]: in function 'pcall'
        ...ck/packer/start/lualine.nvim/lua/lualine/utils/utils.lua:158: in function 'statusline'
        ...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:302: in function <...rvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:287>

This error is because of some poor handling in plenary's async lib (nothing to do with neotest AFAICT)

Error executing luv callback:
...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with th
is message: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: .../packer/start/neotest-python/lua/neotest-python/init.lua:132: bad argument #1
 to 'stream_data' (table expected, got nil)

No, with the minimal config it runs just fine. But uses a terminal to show the log

rcarriga commented 2 years ago

OK I'm closing this issue as it's nothing to do with neotest as far as can be shown. I'd suggest opening an issue with lualine

joshbode commented 2 years ago

not sure the problem is necessarily with lualine - my traceback is simpler:

Error executing vim.schedule lua callback: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:26: bad argument #1 to 'returned_function' (string expected, got nil)
stack traceback:
        [C]: in function 'returned_function'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:26: in function 'callback_or_next'
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:40: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:39>
rcarriga commented 2 years ago

Unfortunately that doesn't say much, just that something went wrong in plenary. Can you reproduce with the minimal init file?

joshbode commented 2 years ago

It looks like the line that's failing is here: https://github.com/nvim-neotest/neotest/blob/master/lua/neotest/consumers/output.lua#L10

and the output field isn't being populated when using the latest version of neotest-python (because the output data is coming from a stream instead?)

this seems to fix things:

  local output = opts.short and result.short or result.output and lib.files.read(result.output)
joshbode commented 2 years ago

I'll make a PR if the above seems logical :)