kickstart.nvim icon indicating copy to clipboard operation
kickstart.nvim copied to clipboard

Failed to load parser: uv_dlopen when on Windows

Open nnako opened this issue 2 years ago • 7 comments

Describe the bug After

  • installing the latest nvim (currently v0.8.2 or v0.9.0-dev) and
  • creating an exact copy of the init.lua file within my local configuration folder C:\Users\<user>\AppData\Local\nvim\,
  • starting nvim from a newly opened command prompt,
  • loading a Python source file,

I see the following error message:

Fehler beim Ausführen von "function <SNR>39_NetrwBrowseChgDir[197]..BufReadPost Autokommandos für "*"":
Error executing lua callback: c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:21:
  Error executing lua: c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:22:
    Vim(append):
      Error executing lua callback:
        Failed to load parser:
          uv_dlopen:
            C:\Users\USER\AppData\Local\nvim-data\site\pack\packer\start\nvim-treesitter\parser\python.so is not a valid Win32 application.
              stack traceback:

              [C]: in function '_ts_add_language'
...0_dev\share\nvim\runtime/lua/vim/treesitter/language.lua:36: in function 'require_language'
...im__v0_9_0_dev\share\nvim\runtime/lua/vim/treesitter.lua:38: in function '_create_parser'
...im__v0_9_0_dev\share\nvim\runtime/lua/vim/treesitter.lua:96: in function 'get_parser'
...im__v0_9_0_dev\share\nvim\runtime/lua/vim/treesitter.lua:330: in function 'start'
...\start\nvim-treesitter/lua/nvim-treesitter/highlight.lua:19: in function 'attach'
...er\start\nvim-treesitter/lua/nvim-treesitter/configs.lua:505: in function 'attach_module'
...er\start\nvim-treesitter/lua/nvim-treesitter/configs.lua:528: in function 'reattach_module'
...er\start\nvim-treesitter/lua/nvim-treesitter/configs.lua:131: in function <...er\start\nvim-treesitter/lua/nvim-treesitter/configs.lua:130>

              [C]: in function 'nvim_cmd'                                                                                                                                 c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:22:
  in function <c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:21>

              [C]: in function 'nvim_buf_call'                                                                                                                            c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:21:
  in function <c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:10>
    stack traceback:

              [C]: in function 'nvim_cmd'
c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:22:
  in function <c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:21>

              [C]: in function 'nvim_buf_call'
c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:21:
  in function <c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:10>
    stack traceback:

              [C]: in function 'nvim_buf_call'
c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:21:
  in function <c:\PROGS\Neovim__v0_9_0_dev\share\nvim\runtime\filetype.lua:10>        

To Reproduce Steps to reproduce the behavior:

  1. start nvim from command line
  2. open any Python file

Desktop (please complete the following information):

  • OS: Windows 10
  • Terminal: cmd

** Neovim Version **

:version
NVIM v0.9.0-dev-622+g08ebf8d3a
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Übersetzt von runneradmin@fv-az276-876
Features: -acl +iconv +tui
See ":help feature-compile"
System-vimrc-Datei: "$VIM\sysinit.vim"
Voreinstellung für $VIM: "C:/Program Files (x86)/nvim/share/nvim"
Run :checkhealth for more info

nnako avatar Jan 06 '23 07:01 nnako

My output of my version

NVIM v0.8.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compiled by runneradmin@fv-az28-353
Features: -acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM\sysinit.vim"
fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

I did not encounter a problem. For C++, I used skeevo's wdevkit Also, I used chocolatey on windows to download and install neovim Installed on 6 Jan 2023

shanujha avatar Jan 06 '23 12:01 shanujha

Hi @shanujha ,

thanks for your reply.

It seems to me that the nvim-treesitter plugin does not install correctly on Windows systems, as there are compiled files ending on so within it's plugin folder:

C:\Users\USER\AppData\Local\nvim-data\site\pack\packer\start\nvim-treesitter\parser\

contains a python.so file which "is not a valid Win32 application", according to the error message further above. Does nvim-treesitter install correctly on Windows systems from source, anyway?

nnako avatar Jan 07 '23 09:01 nnako

ok. found this article:

https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support

where it seems to describe the problem experienced here with the nvim-treesitter plugin. will have to look at it later, as I have only very little time... will stick to gvim for now...

nnako avatar Jan 07 '23 09:01 nnako

I'm stuck, too. No problems on my Mac, but trying to use kickstart.nvim on my Windows machine throws the above error at me. Interestingly, the .so files indeed do contain the usual Windows signature, so I did rename them to .dll files. After restart, new .so files were being generated, but now Neovim tried to load the .dll files. Unfortunately, the error message stays the same - in my case ".../lua.dll is not a valid Win32 application.".

I did have a look into my lua.dll using https://www.nirsoft.net/utils/dll_export_viewer.html and it loaded fine, the .dll seems to be okay. Strange. Any ideas?

thoralt avatar Jan 21 '23 18:01 thoralt

Are people still have problems with this? Can you try the latest version of kickstart and see if you still are having problems.

tjdevries avatar Feb 17 '23 21:02 tjdevries

Yes, just retried it on a Windows 11 22H2, and still having all the treesitter parsers as .so files (in ~/AppData/Local/nvim-data/lazy/nvim-treesitter/parsers/), which sounds like Linux-files, not Windows-files.

tiavision avatar Feb 17 '23 22:02 tiavision

For me the problem was that the compiler was the x86 version, not the x64 version. Solution to this particular problem can be found here: https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support#msvc (use the x64 Native Tools Command Prompt)

tiavision avatar Feb 17 '23 23:02 tiavision

I didn't have problems with treesitter when launching a x64 Native Tools Command Prompt (which basically just runs "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" )

DavidBChristensen avatar Apr 14 '23 00:04 DavidBChristensen

Hi guys! This looks exactly the same as the upstream Treesitter issue.

And they've closed that one. @TimHeinrich @nnako @shanujha could you please hop over there and see if the provided details fix this issue?

feoh avatar Apr 18 '23 15:04 feoh

I checked the issue mentioned by @feoh . Seems like the general solution was to intentionally change the treesitter compiler to either clang or zig. In the issue, kind people have also mentioned how to install clang or zig. Would also like to mention that make sure you are using 64 bit windows, and/or if you are using MinGW use the 64 bit version rather than 32 bit.

Since I was unable to reproduce the issue, if others are facing it, would you be kind enough to update it here after following the steps highlighted in this issue.

shanujha avatar Apr 19 '23 07:04 shanujha

Also, it seems pretty clear to me that this isn't an issue of configuration and is in fact an issue with Treesitter itself.

If you're still having problems, please go ahead and open a detailed issue over on their repo where there are more people with more expertise to help get you sorted.

Please feel free to re-open if you disagree but I'm closing this for now.

feoh avatar Apr 19 '23 14:04 feoh

Error detected while processing FileType Autocommands for "*": Error executing lua callback: Failed to load parser for language 'vimdoc': uv_dlopen:

im getting it still, just tried - :help, and this is the error i got

sail1369 avatar Oct 28 '23 11:10 sail1369

Error detected while processing FileType Autocommands for "*": Error executing lua callback: Failed to load parser for language 'vimdoc': uv_dlopen:

im getting it still, just tried - :help, and this is the error i got

Same here. Getting the exact same error

di-void avatar Dec 08 '23 21:12 di-void

So, for anyone who still encounters that, I want to say that yeah, for me the parsers still fail to compile properly. I use the x64 VS 2022 native prompt for that, and the clang -v, cc -v and gcc -v all show that they are 64bit versions. I tried juggling them in the treesitter compiler settings, but to no avail. I'm not sure what still went wrong, and honestly all this out of hand ABI shit is already getting old.

What helped me was using zig instead. So here's the exact steps that I used:

  • Install zig via scoop or chocolatey or elsehow
  • Have neovim, kickstart, and all that
  • In the treesitter config in the main init.lua add the require('nvim-treesitter.install').compilers = {"zig"} line
  • Delete the nvim-data folder if you had it, and open neovim
  • :checkhealth treesitter should now show that everything is OK.

Example, how my treesitter config looks for making this work:

    config = function(_, opts)
      -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
      require('nvim-treesitter.install').compilers = {"zig", "clang", "gcc"}

      ---@diagnostic disable-next-line: missing-fields
      require('nvim-treesitter.configs').setup(opts)

      -- There are additional nvim-treesitter modules that you can use to interact
      -- with nvim-treesitter. You should go explore a few and see what interests you:
      --
      --    - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
      --    - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
      --    - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
    end,

Yeah so this requires installing zig, if you don't have it, but I don't think it is an issue. Maybe there's a better solution, but I have no spare day to waste it on something like this.

noncom avatar Aug 05 '24 18:08 noncom