williamboman / mason.nvim

Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.
Apache License 2.0
7.71k stars 271 forks source link

Can not find the installed lsp server executable file in windows #478

Closed lost22git closed 2 years ago

lost22git commented 2 years ago

I believe this to be an issue that should be addressed by maintainers of mason.nvim.

Why do you think this is an issue with mason.nvim?

Can not find the installed lsp server executable file in windows

Neovim version (>= 0.7)

NVIM v0.7.2 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compiled by runneradmin@fv-az276-503

Operating system/version

win11

I've manually reviewed logs to find potential errors

I've recently downloaded the latest plugin version of mason.nvim

Affected packages

all

Problem description

image

image

image

MasonLog

No content

LspLog

[START][2022-09-29 01:02:42] LSP logging initiated
[WARN][2022-09-29 01:02:44] ...lsp/handlers.lua:110 "The language server tailwindcss triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ERROR][2022-09-29 01:02:44] ...lsp/handlers.lua:455    "Tailwind CSS: No config file found.\nError\n    at new Rf (C:\\Users\\zzz\\AppData\\Local\\nvim-data\\mason\\packages\\tailwindcss-language-server\\node_modules\\@tailwindcss\\language-server\\bin\\tailwindcss-language-server:271:319)\n    at C:\\Users\\zzz\\AppData\\Local\\nvim-data\\mason\\packages\\tailwindcss-language-server\\node_modules\\@tailwindcss\\language-server\\bin\\tailwindcss-language-server:693:4714\n    at Generator.next (<anonymous>)\n    at i (C:\\Users\\zzz\\AppData\\Local\\nvim-data\\mason\\packages\\tailwindcss-language-server\\node_modules\\@tailwindcss\\language-server\\bin\\tailwindcss-language-server:2:1059)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"

Steps to reproduce

  1. MasonInstall typescript-language-server
  2. config tsserver in lspconfig

    require('lspconfig').tsserver.setup {
    on_attach = on_attach,
    filetypes = { "typescript", "typescriptreact", "typescript.tsx" },
    cmd = { "typescript-language-server", "--stdio" },
    
    capabilities = capabilities
    }

    config mason lspconfig

    lspconfig.setup {
    automatic_installation = true,
    }
  3. nvim test.ts

Actual behavior

Can not find the ts server executable file in windows

Expected behavior

ts lsp server start successuflly when open ts file

Healthcheck

mason: require("mason.health").check()
========================================================================
## mason.nvim report
  - OK: neovim version >= 0.7.0
  - WARNING: **Go**: not available
  - OK: **cargo**: `cargo 1.62.1 (a748cf5a3 2022-06-08)`
  - WARNING: **luarocks**: not available
  - WARNING: **Ruby**: not available
  - WARNING: **RubyGem**: not available
  - WARNING: **Composer**: not available
  - WARNING: **PHP**: not available
  - OK: **npm**: `8.19.1`
  - OK: **node**: `v18.9.1
`
  - OK: **python3**: `Python 3.10.7
`
  - OK: **pip3**: `pip 22.2.2 from E:\scoop\global\apps\python\current\lib\site-packages\pip (python 3.10)

`
  - OK: **javac**: `javac 19
`
  - OK: **java**: `openjdk version "19" 2022-09-20
`
  - WARNING: **julia**: not available
  - ERROR: **wget**: not available
  - OK: **curl**: `curl 7.83.1 (Windows) libcurl/7.83.1 Schannel
`
  - ERROR: **gzip**: not available
  - OK: **tar**: `bsdtar 3.5.2 - libarchive 3.5.2 zlib/1.2.5.f-ipp bz2lib/1.0.6 
`
  - OK: **python**: `Ok`
  - OK: **pip**: `pip 22.2.2 from E:\scoop\global\apps\python\current\lib\site-packages\pip (python 3.10)

`
  - OK: **JAVA_HOME**: `openjdk version "19" 2022-09-20
`
  - OK: GitHub API rate limit. Used: 15. Remaining: 45. Limit: 60. Reset: 2022/9/29 1:19:16.

Screenshots or recordings

No response

lost22git commented 2 years ago

the same problem even if manually add %LOCALAPPDATA%\nvim-data\mason\bin to PATH

> $env:PATH | rg -i mason

image

image

williamboman commented 2 years ago

Hello! So on Windows, Neovim (or more precisely libuv) doesn't recognize .cmd commands in PATH. libuv is used by Neovim's LSP client to start servers. You have a few options:

lost22git commented 2 years ago

@williamboman Thank you for your timely response.

don't provide a cmd override when setting up the server (the cmd you provided is the default anyway)

This approach is not always successful, for example, it fails under zls.

But vim.fn.exepath works for me now

williamboman commented 2 years ago

Ah yeah there are a few servers who cmd needs to be patched on Windows, for the same underlying reason as above. mason-lspconfig patches these cmds automatically for you.