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

Can't install parser with shellslash option enabled on Windows #2844

Closed
EtiamNullam opened this issue Apr 19, 2022 · 11 comments · Fixed by #3899
Closed

Can't install parser with shellslash option enabled on Windows #2844

EtiamNullam opened this issue Apr 19, 2022 · 11 comments · Fixed by #3899
Labels
bug Something isn't working platform Windows Issues that are specific to Windows

Comments

@EtiamNullam
Copy link

Describe the bug

This error is shown when attempting to install language parser with shellslash option enabled:

nvim-treesitter[lua]: Failed to execute the following command:
{
  cmd = "cmd",
  opts = {
    args = { "/C", "if", "exist", "C:\\Users\\user\\AppData\\Local/nvim-data\\tree-sitter-lua", "rmdir", "/s", "/q", "C:\\Users\\user\\AppData\\Local/nvim-data\\tree-sitter-lua" },
    stdio = {
      [2] = <userdata 1>,
      [3] = <userdata 2>
    }
  }
}
Invalid switch - "nvim-data\tree-sitter-lua".^M

To Reproduce

Example with lua:

  1. :set shellslash
  2. :TSInstall lua
  3. Press y to reinstall if lua is already installed.
  4. Notice execution of command via cmd (rmdir, see Describe the bug section for full message) will fail with message: Invalid switch - "nvim-data\tree-sitter-lua".^M

Expected behavior

Installation and update of language parsers should be possible no matter what is the setting of shellslash option.

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - OK: `tree-sitter` found 0.20.6 (ccd6bf554d922596ce905730d98a77af368bba5c) (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v16.14.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `gcc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: gcc.exe (GCC) 10.2.0
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - gdscript       ✓ ✓ . ✓ ✓ 
  - cooklang       ✓ . . . . 
  - rst            ✓ ✓ . . ✓ 
  - slint          ✓ . . ✓ . 
  - godot_resource ✓ ✓ ✓ . . 
  - css            ✓ . ✓ ✓ ✓ 
  - graphql        ✓ . . ✓ ✓ 
  - vala           ✓ . . . . 
  - turtle         ✓ ✓ ✓ ✓ ✓ 
  - json           ✓ ✓ ✓ ✓ . 
  - devicetree     ✓ ✓ ✓ ✓ ✓ 
  - yaml           ✓ ✓ ✓ ✓ ✓ 
  - dart           ✓ ✓ . ✓ ✓ 
  - markdown       ✓ . ✓ . ✓ 
  - d              ✓ . ✓ ✓ ✓ 
  - bash           ✓ ✓ ✓ . ✓ 
  - hcl            ✓ . ✓ ✓ ✓ 
  - glimmer        ✓ . . . . 
  - r              ✓ ✓ . ✓ ✓ 
  - dockerfile     ✓ . . . ✓ 
  - gleam          ✓ ✓ ✓ ✓ ✓ 
  - query          ✓ ✓ ✓ ✓ ✓ 
  - surface        ✓ . ✓ ✓ ✓ 
  - wgsl           ✓ . ✓ . . 
  - todotxt        ✓ . . . . 
  - fortran        ✓ . ✓ ✓ . 
  - eex            ✓ . . . ✓ 
  - rego           ✓ . . . ✓ 
  - javascript     ✓ ✓ ✓ ✓ ✓ 
  - elvish         ✓ . . . ✓ 
  - ocaml_interface✓ ✓ ✓ . ✓ 
  - elm            ✓ . . . ✓ 
  - nix            ✓ ✓ ✓ . ✓ 
  - ocamllex       ✓ . . . ✓ 
  - ruby           ✓ ✓ ✓ ✓ ✓ 
  - cpp            ✓ ✓ ✓ ✓ ✓ 
  - solidity       ✓ . . . . 
  - c_sharp        ✓ ✓ ✓ . ✓ 
  - norg           . . . . . 
  - typescript     ✓ ✓ ✓ ✓ ✓ 
  - cuda           ✓ ✓ ✓ ✓ ✓ 
  - hack           ✓ . . . . 
  - scala          ✓ . ✓ . ✓ 
  - foam           ✓ ✓ ✓ ✓ ✓ 
  - rasi           ✓ ✓ ✓ ✓ . 
  - scss           ✓ . . ✓ . 
  - glsl           ✓ ✓ ✓ ✓ ✓ 
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
  - make           ✓ . . . ✓ 
  - html           ✓ ✓ ✓ ✓ ✓ 
  - beancount      ✓ . ✓ . . 
  - astro          ✓ ✓ ✓ ✓ ✓ 
  - cmake          ✓ . ✓ . . 
  - fusion         ✓ ✓ ✓ ✓ . 
  - fish           ✓ ✓ ✓ ✓ ✓ 
  - elixir         ✓ ✓ ✓ ✓ ✓ 
  - tlaplus        ✓ ✓ ✓ . ✓ 
  - hjson          ✓ ✓ ✓ ✓ ✓ 
  - clojure        ✓ ✓ ✓ . ✓ 
  - bibtex         ✓ . ✓ ✓ . 
  - php            ✓ ✓ ✓ ✓ ✓ 
  - pioasm         ✓ . . . ✓ 
  - dot            ✓ . . . ✓ 
  - kotlin         ✓ ✓ ✓ . ✓ 
  - vim            ✓ ✓ . . ✓ 
  - erlang         . . . . . 
  - pug            ✓ . . . ✓ 
  - svelte         ✓ . ✓ ✓ ✓ 
  - json5          ✓ . . . ✓ 
  - python         ✓ ✓ ✓ ✓ ✓ 
  - heex           ✓ ✓ ✓ ✓ ✓ 
  - rust           ✓ ✓ ✓ ✓ ✓ 
  - help           ✓ . . . . 
  - gomod          ✓ . . . ✓ 
  - swift          ✓ ✓ . . . 
  - yang           ✓ . ✓ . . 
  - hocon          ✓ . . . ✓ 
  - latex          ✓ . ✓ . ✓ 
  - ninja          ✓ . ✓ ✓ . 
  - llvm           ✓ . . . . 
  - regex          ✓ . . . . 
  - zig            ✓ . ✓ ✓ ✓ 
  - http           ✓ . . . ✓ 
  - jsonc          ✓ ✓ ✓ ✓ ✓ 
  - sparql         ✓ ✓ ✓ ✓ ✓ 
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - toml           ✓ ✓ ✓ ✓ ✓ 
  - jsdoc          ✓ . . . . 
  - teal           ✓ ✓ ✓ ✓ ✓ 
  - scheme         ✓ . ✓ . ✓ 
  - pascal         ✓ ✓ ✓ ✓ ✓ 
  - verilog        ✓ ✓ ✓ . ✓ 
  - ql             ✓ ✓ . ✓ ✓ 
  - c              ✓ ✓ ✓ ✓ ✓ 
  - java           ✓ ✓ . ✓ ✓ 
  - tsx            ✓ ✓ ✓ ✓ ✓ 
  - fennel         ✓ ✓ . . ✓ 
  - ocaml          ✓ ✓ ✓ . ✓ 
  - haskell        ✓ . . . ✓ 
  - commonlisp     ✓ ✓ ✓ . . 
  - go             ✓ ✓ ✓ ✓ ✓ 
  - comment        ✓ . . . . 
  - gowork         ✓ . . . ✓ 
  - perl           ✓ . ✓ . . 
  - vue            ✓ . ✓ ✓ ✓ 
  - lalrpop        ✓ ✓ . . . 
  - prisma         ✓ . . . . 
  - ledger         ✓ . ✓ ✓ ✓ 

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.7.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compiled by runneradmin@fv-az320-113

Features: -acl +iconv +tui

Additional context

lua is just an example, it seems like no language parser can be installed with shellslash option enabled.

@EtiamNullam EtiamNullam added the bug Something isn't working label Apr 19, 2022
@EtiamNullam
Copy link
Author

Might be the same problem as #1965, not enough info there though.

@sakhnik
Copy link

sakhnik commented Sep 24, 2022

I'm also interested in this fix and can help reproduce it.
Whenever I configure neovim on a new Windows VM, I should make sure noshellslash is configured for the TS parsers build to succeed. Otherwise, note that the cmd argument contains a forward slash and the build fails:

    args = { "/C", "if", "exist", "C:\\Users\\user\\AppData\\Local/nvim-data\\tree-sitter-lua", "rmdir", "/s", "/q", "C:\\Users\\user\\AppData\\Local/nvim-data\\tree-sitter-lua" },
                                                               -->|

A quick search led to utils.get_cache_dir():

local cache_dir = fn.stdpath "data"

Apparently, the slash is returned by Neovim. I see there already are a few substitutions for the correct path separator in the plugin. Maybe it's worth fixing the path separator right here?

Or at least in select_install_rm_cmd for the argument cache_folder?

local dir = cache_folder .. "\\" .. project_name

@vimode
Copy link

vimode commented Nov 26, 2022

I have this issue with shellslash enabled or disabled but only for installing lua. Rest all other parsers installed properly.

Any suggestions?

Edit: I deleted the lua.so file from C:\Users\user\AppData\Local\nvim-data\site\pack\packer\start\nvim-treesitter\parser

Ran :TSUpdate again and it was able to install properly without throwing any error. 🤷

EDIT: This solution might be working for when you are getting access denied at the end of the error message. Read @EtiamNullam 's message below for more details.

@vimode
Copy link

vimode commented Nov 26, 2022

Please add the platform-windows label to this issue, it would be easier to find this for anyone else facing this issue. Thank you.

@clason clason added the platform Windows Issues that are specific to Windows label Nov 26, 2022
@EtiamNullam
Copy link
Author

@vimode Are you sure the error you've is exactly the same?

I believe you cannot remove or update parser for a language which is in use on Windows (like if you have an open buffer which uses it), I guess it has something to do with the fact that you cannot remove files which are in use on Windows, but I believe the error message is different, like "access denied".

@vimode
Copy link

vimode commented Nov 27, 2022

@EtiamNullam

I believe you cannot remove or update parser for a language which is in use on Windows (like if you have an open buffer which uses it),

Interesting, I think that might be reason why I wasn't able to update it and after deleting it I was able to install it again.

I had access denied with TSUpdate which was also interrupting updating other parsers.

But with TSInstall I was not getting access denied but with same issues of executing .

{
  cmd = "cmd",
  opts = {
    args = { "/C", "if", "exist",. ..
    stdio = {
      [2] = <userdata 1>,
      [3] = <userdata 2>
    }
  }
}

Now that you mentioned I will try to find a screenshot if I have to be certain what it was, I am sure it wasn't access denied at the end of the error.

Till I find a screenshot I will edit my comment above to update with this info.

Thank you.

tajtiattila added a commit to tajtiattila/nvim-treesitter that referenced this issue Nov 30, 2022
tajtiattila added a commit to tajtiattila/nvim-treesitter that referenced this issue Nov 30, 2022
tajtiattila added a commit to tajtiattila/nvim-treesitter that referenced this issue Nov 30, 2022
tajtiattila added a commit to tajtiattila/nvim-treesitter that referenced this issue Nov 30, 2022
Always use backlashes as path separators
in commands when they are used in cmd.exe.

Fixes nvim-treesitter#2844 nvim-treesitter#1965
theHamsta pushed a commit that referenced this issue Dec 14, 2022
Always use backlashes as path separators
in commands when they are used in cmd.exe.

Fixes #2844 #1965
@js-writer
Copy link

Still not working on windows.

@js-writer
Copy link

js-writer commented Feb 6, 2023

Why is this close?!
This error is still here.
Windows 10.
Nvim 0.9.

nvim-treesitter[help]: Failed to execute the following command:
{
  cmd = "cmd",
  opts = {
    args = { "/C", "if", "exist", "C:\\Users\\<myuser>\\AppData\\Local\\nvim-data\\tree-sitter-help", "rmdir", "/s", "/q",                      "C:\\Users\\<myuser>\\AppData\\Local\\nvim-data\\tree-sitter-help" },
    stdio = {
      [2] = <userdata 1>,
      [3] = <userdata 2>
    }
  }
}

Same was with lua so I deleted it from ensure_installed.
Im also getting this error:
Could not load parser for lua: "Failed to load parser: uv_dlopen: C:\\Users\\<myuser>\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\nvim-treesitter\\parser\\lua.so is not proper Win21 application\r\n"

@theHamsta
Copy link
Member

theHamsta commented Feb 6, 2023

Why is this close?! This error is still here. Windows 10. Nvim 0.9.

nvim-treesitter[help]: Failed to execute the following command:
{
  cmd = "cmd",
  opts = {
    args = { "/C", "if", "exist", "C:\\Users\\<myuser>\\AppData\\Local\\nvim-data\\tree-sitter-help", "rmdir", "/s", "/q",                      "C:\\Users\\<myuser>\\AppData\\Local\\nvim-data\\tree-sitter-help" },
    stdio = {
      [2] = <userdata 1>,
      [3] = <userdata 2>
    }
  }
}

Same was with lua so I deleted it from ensure_installed. Im also getting this error: Could not load parser for lua: "Failed to load parser: uv_dlopen: C:\\Users\\<myuser>\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\nvim-treesitter\\parser\\lua.so is not proper Win21 application\r\n"

Your error shows that the installation worked. You have an error loading the compiled extension that apparently succeeded compiling. This is unlikely related to shellslash but rather the compiler setup. The compiled lua.so doesn't seem to be the right architecture for Neovim.

@js-writer
Copy link

js-writer commented Feb 6, 2023

@theHamsta ok, thx. So is there anything that I can do to fix it?

[Edit]
I fixed it by installing x64 version on gcc following this guide:
https://code.visualstudio.com/docs/cpp/config-mingw

Thank you @theHamsta for advice.

@yashgosa
Copy link

yashgosa commented Dec 4, 2023

I solved by:

  1. Open the terminal with admin previlages
  2. Following this GFG artical, basically turn off the anti virus

@nvim-treesitter nvim-treesitter locked as resolved and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working platform Windows Issues that are specific to Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants