Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] language name error when running any type of python test #384

Open
sho-87 opened this issue Mar 23, 2024 · 2 comments
Open

[BUG] language name error when running any type of python test #384

sho-87 opened this issue Mar 23, 2024 · 2 comments
Assignees

Comments

@sho-87
Copy link

sho-87 commented Mar 23, 2024

Error

I get the following error in neotest.log whenever I try to run a single test file or a directory of tests:

WARN | 2024-03-15T23:53:17Z-0700 | ...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:164 | CHILD | Error in remote call ...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:87: '' is not a valid language name
stack traceback:
	[C]: in function 'error'
	...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:87: in function 'add'
	...m/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:98: in function 'get_string_parser'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:119: in function 'get_parse_root'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'func'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:156: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155>
	[C]: in function 'xpcall'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:154>

all errors in the log file are the same as above, apart from 2 instances of this:

WARN | 2024-03-15T23:26:14Z-0700 | ...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:164 | CHILD | Error in remote call error converting argument 4
stack traceback:
	[C]: in function 'rpcnotify'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:126: in function 'notify'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:165: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:162>
	[C]: in function 'error'
	...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:87: in function 'add'
	...m/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:98: in function 'get_string_parser'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:119: in function 'get_parse_root'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'func'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:156: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155>
	[C]: in function 'xpcall'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:154>

Details

nvim --version:

NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1703942320
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe /MD /Zi /O2 /Ob1  -W3 -wd4311 -wd4146 -DUNIT_TESTING -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0602 -DMSWIN -DINCLUDE_GENERATED_DECLARATIONS -ID:/a/neovim/neovim/.deps/usr/include/luajit-2.1 -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include -ID:/a/neovim/neovim/build/cmake.config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include
-ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

The project is managed using Poetry and has the following structure. Running poetry run pytest outside of nvim runs fine:

image

Im using lazyvim and have installed neotest using the extras package, but I have also tested this manually with this config:

return {
  {
    "folke/neodev.nvim",
    opts = {
      library = {
        plugins = { "neotest" },
        types = true,
      },
    },
  },
  {
    "nvim-neotest/neotest",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
      "nvim-neotest/neotest-go",
      "nvim-neotest/neotest-python",
    },
    opts = {
      default_strategy = "integrated",
      discovery = {
        enabled = true,
      },
      adapters = {
        require("neotest-go"),
        require("neotest-python")({
          runner = "pytest",
          python = "C:\\Users\\simon\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\herald-of-completion-NCjgh5TX-py3.11\\Scripts",
          -- python = ".venv/bin/python",
        }),
      },
    },
  },
}

all of my venvs are in the default poetry directory (rather than in separate project directories). I activate the relevant venv using venv-selector

it seems that test discovery works fine as the summary window shows them all correctly, just nothing happens (apart from the logged error) when I run require("neotest").run.run(vim.fn.expand("%"))

image

given how often treesitter appears in the log, I also tried recompiling the grammar for python but that didn't fix the problem

@Nosterx
Copy link

Nosterx commented Apr 11, 2024

I'm facing a similar issue now. I managed to trace it back to the filetype detection in the 'plenary/filetype.lua' file. It seems that Plenary's filetype_table was not populated for some reason. The snippet below fixes the issue for Python.
in plenary/filetype.lua:8

local filetype_table = {
  extension = { py = "python" },
  file_name = {},
  shebang = {},
}

@Quitlox
Copy link
Contributor

Quitlox commented Jul 29, 2024

I also ran into this problem. For me, the problem was an outdated plenary.nvim (semver/luarocks are behind). Switching to the last commit on master fixed it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants