Martins3 / My-Linux-Config

:clap: Modern neovim configuration based on native lsp
https://martins3.github.io/My-Linux-Config/
GNU General Public License v3.0
335 stars 62 forks source link

mason-lspconfig: failed to install nil_ls #149

Closed txctxc closed 9 months ago

txctxc commented 10 months ago

I've searched open issues and searched on the Internet for similar requests

Installed
    ◍ css-lsp cssls
    ◍ efm
    ◍ html-lsp html
    ◍ json-lsp jsonls
    ◍ lua-language-server lua_ls
    ◍ marksman
    ◍ pyright
    ◍ rust-analyzer rust_analyzer
    ◍ vim-language-server vimls
    ◍ yaml-language-server yamlls
NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Ubuntu22.04.3 LTS
Linux version 6.2.0-36-generic (buildd@lcy02-amd64-050) (x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  9 15:34:04 UTC 2
==============================================================================
mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.8.2
- OK PATH: append
- OK Providers: 
  mason.providers.registry-api
  mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2023-11-03-jaunty-cello` is installed.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.`
- OK wget: `GNU Wget 1.21.2 built on linux-gnu.`
- OK curl: `curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.16`
- OK gzip: `gzip 1.10`
- OK tar: `tar (GNU tar) 1.34`
- OK bash: `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- WARNING Go: not available
  - ADVICE:
    - spawn: go failed with exit code - and signal -. go is not executable
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
  - ADVICE:
    - spawn: php failed with exit code - and signal -. php is not executable
- WARNING luarocks: not available
  - ADVICE:
    - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- WARNING Ruby: not available
  - ADVICE:
    - spawn: ruby failed with exit code - and signal -. ruby is not executable
- WARNING javac: not available
  - ADVICE:
    - spawn: javac failed with exit code - and signal -. javac is not executable
- WARNING java: not available
  - ADVICE:
    - spawn: java failed with exit code - and signal -. java is not executable
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- WARNING RubyGem: not available
  - ADVICE:
    - spawn: gem failed with exit code - and signal -. gem is not executable
- OK python: `Python 3.10.12`
- OK cargo: `cargo 1.66.1`
- OK python3_host_prog: `Python 3.8.18`
- WARNING node: unsupported version `v12.22.9`
  - ADVICE:
    - Node version must be >= 14
- OK python3_host_prog pip: `pip 23.3 from /home/t/miniconda3/envs/pynvim/lib/python3.8/site-packages/pip (python 3.8)`
- OK pip: `pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)`
- OK npm: `8.5.1`
- OK python venv: `Ok`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 7. Remaining: 53. Limit: 60. Reset: 2023年11月04日 星期六 04时25分58秒.
  Install and authenticate via gh-cli to increase rate limit.
require("mason").setup{
    log_level = vim.log.levels.DEBUG
}

into /home/t/.dotfiles/nvim/lua/usr/lsp/mason.lua.

Here is the mason log information in more detail:

[INFO  2023年11月04日 星期六 03时32分44秒] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:184: Executing installer for Package(name=nil) {}
[DEBUG 2023年11月04日 星期六 03时32分44秒] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:58: Attempting to lock package Package(name=nil)
[DEBUG 2023年11月04日 星期六 03时32分44秒] ...are/nvim/lazy/mason.nvim/lua/mason-core/package/init.lua:148: Handle InstallHandle(package=Package(name=nil), state=ACTIVE) already exist for package Package(name=nil)
[DEBUG 2023年11月04日 星期六 03时32分44秒] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:70: Wrote lockfile Package(name=nil)
[DEBUG 2023年11月04日 星期六 03时32分44秒] .../.local/share/nvim/lazy/mason.nvim/lua/mason-core/fs.lua:71: fs: mkdirp /home/t/.local/share/nvim/mason/staging/nil
[DEBUG 2023年11月04日 星期六 03时32分44秒] ...zy/mason.nvim/lua/mason-core/installer/registry/init.lua:148: Compiling installer. nil {}
[DEBUG 2023年11月04日 星期六 03时32分44秒] ...y/mason.nvim/lua/mason-core/installer/managers/cargo.lua:16: cargo: install "nil" "2023-08-09" {
  git = {
    rev = false,
    url = "https://github.com/oxalica/nil"
  },
  locked = true
}
[DEBUG 2023年11月04日 星期六 03时32分44秒] ...al/share/nvim/lazy/mason.nvim/lua/mason-core/process.lua:116: Spawning cmd="cargo", spawn_opts={
  args = { "install", "--root", ".", "--git", "https://github.com/oxalica/nil", "--tag", "2023-08-09", "--locked", "nil" },
  cwd = "/home/t/.local/share/nvim/mason/staging/nil"
}
[DEBUG 2023年11月04日 星期六 03时32分44秒] ...al/share/nvim/lazy/mason.nvim/lua/mason-core/process.lua:162: Spawned with pid 1040544
[DEBUG 2023年11月04日 星期六 03时32分47秒] ...al/share/nvim/lazy/mason.nvim/lua/mason-core/process.lua:148: Job pid=1040544 exited with exit_code=101, signal=0
[DEBUG 2023年11月04日 星期六 03时32分47秒] .../.local/share/nvim/lazy/mason.nvim/lua/mason-core/fs.lua:59: fs: unlink /home/t/.local/share/nvim/mason/staging/nil.lock
[DEBUG 2023年11月04日 星期六 03时32分47秒] .../.local/share/nvim/lazy/mason.nvim/lua/mason-core/fs.lua:47: fs: rmrf /home/t/.local/share/nvim/mason/staging/nil
[DEBUG 2023年11月04日 星期六 03时32分47秒] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:39: Building receipt for Package(name=nil)
[ERROR 2023年11月04日 星期六 03时32分47秒] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:249: Installation failed for Package(name=nil) error=spawn: cargo failed with exit code 101 and signal 0. 
Martins3 commented 10 months ago

Can you apply this patch and try again?

diff --git a/nvim/lua/usr/lsp/mason.lua b/nvim/lua/usr/lsp/mason.lua
index 8d79e98f5374..e9d68e1ee6d7 100644
--- a/nvim/lua/usr/lsp/mason.lua
+++ b/nvim/lua/usr/lsp/mason.lua
@@ -1,7 +1,6 @@
 -- 在 https://github.com/williamboman/mason-lspconfig.nvim 中含有所有支持的 lsp
 local servers = {
   "lua_ls",
-  "nil_ls",
   "cssls",
   "html",
   -- "tsserver",
@@ -39,7 +38,7 @@ if not lspconfig_status_ok then
   return
 end

-local all_servers = {"ccls"}
+local all_servers = {"ccls", "nil_ls"}
 for i = 1, #servers do
   all_servers[#all_servers + 1] = servers[i]
 end
txctxc commented 10 months ago

Can you apply this patch and try again?

diff --git a/nvim/lua/usr/lsp/mason.lua b/nvim/lua/usr/lsp/mason.lua
index 8d79e98f5374..e9d68e1ee6d7 100644
--- a/nvim/lua/usr/lsp/mason.lua
+++ b/nvim/lua/usr/lsp/mason.lua
@@ -1,7 +1,6 @@
 -- 在 https://github.com/williamboman/mason-lspconfig.nvim 中含有所有支持的 lsp
 local servers = {
   "lua_ls",
-  "nil_ls",
   "cssls",
   "html",
   -- "tsserver",
@@ -39,7 +38,7 @@ if not lspconfig_status_ok then
   return
 end

-local all_servers = {"ccls"}
+local all_servers = {"ccls", "nil_ls"}
 for i = 1, #servers do
   all_servers[#all_servers + 1] = servers[i]
 end

After applying this patch, the bug still exists, and Mason Log DEBUG shows as: 1J3UR3GAO14AGV`V9`DUKF7

The previous line [DEBUG 2023年11月04日 星期六 03时32分44秒] ...are/nvim/lazy/mason.nvim/lua/mason-core/package/init.lua:148: Handle InstallHandle(package=Package(name=nil), state=ACTIVE) already exist for package Package(name=nil) is not displayed.

Martins3 commented 10 months ago

execute this command in nim :MasonUninstall nil

txctxc commented 10 months ago

I executed this command in Neovim :MasonUninstall nil image

The bug still exists. After that, I restarted my computer, opened Neovim, MasonLog DEBUG shows: L6J 4PO0`6HBS$9`P1``U{J

txctxc commented 10 months ago

I searched on the Internet, and found onehttps://www.reddit.com/r/neovim/comments/zf44kc/cant_install_assembly_server_asm_lsp_with_mason/ with this bug:

spawn: cargo failed with exit code 101 and signal 0.

Our situations are not exactly the same. image Then I turned to https://github.com/williamboman/mason.nvim/issues/580#event-7953440352 but I do not understand it. I can not find file~/mason.nvim/lua/mason-core/managers/cargo/init.lua on my computer.

Martins3 commented 10 months ago
  1. Mason will automatically download the source code of lsp and compile it locally
  2. nil_ls^1 is a nix language server. To compile it, nix is required. I'm using nixos, so the config works for me.
  3. After the patch, the nil_ls shouldn't managed by the mason. But maybe caused the cached or something else, mason.nvim still try to install nil_ls
Martins3 commented 10 months ago

should me the result of "ls ~/.local/share/nvim/mason/staging"

Martins3 commented 10 months ago

I searched on the Internet, and found onehttps://www.reddit.com/r/neovim/comments/zf44kc/cant_install_assembly_server_asm_lsp_with_mason/ with this bug:↳

spawn: cargo failed with exit code 101 and signal 0.

Our situations are not exactly the same. image Then I turned to williamboman/mason.nvim#580 (comment) but I do not understand it. I can not find file~/mason.nvim/lua/mason-core/managers/cargo/init.lua on my computer.↳

I think this is unrelated

txctxc commented 10 months ago

image

txctxc commented 10 months ago
  1. Mason will automatically download the source code of lsp and compile it locally
  2. nil_ls1 is a nix language server. To compile it, nix is required. I'm using nixos, so the config works for me.
  3. After the patch, the nil_ls shouldn't managed by the mason. But maybe caused the cached or something else, mason.nvim still try to install nil_ls

Footnotes

  1. https://github.com/oxalica/nil

Yes, it might be because our operating system is different. https://github.com/williamboman/mason-lspconfig.nvim shows rnix is also a LSP for Nix language. As a result, I installed rnix instead of nil_ls. It works for me. image

txctxc commented 10 months ago
  1. Mason will automatically download the source code of lsp and compile it locally
  2. nil_ls1 is a nix language server. To compile it, nix is required. I'm using nixos, so the config works for me.
  3. After the patch, the nil_ls shouldn't managed by the mason. But maybe caused the cached or something else, mason.nvim still try to install nil_ls

Footnotes

  1. https://github.com/oxalica/nil

Thank you for your help. It's too difficult for me to understand these now. Maybe I can study it later and use another LSP as a replacement for now.

Martins3 commented 10 months ago

Can you apply the patch, and check whether the bug still exists.

txctxc commented 10 months ago

Can you apply the patch, and check whether the bug still exists.您能否应用补丁,并检查错误是否仍然存在。

I followed Nix 详解(一) 像传统包管理器一样使用 Nix to install Nix on my Ubuntu. image

Then I applied this change:

-- 在 https://github.com/williamboman/mason-lspconfig.nvim 中含有所有支持的 lsp
  local servers = {
    "lua_ls",
    "nil_ls",
+   -- "rnix",
    "cssls",
    "html",
    -- "tsserver",
    "pyright",
    "rust_analyzer",
    "jsonls",
    "yamlls",
    "efm",
    "vimls",
    "marksman",
  }

Open Neovim, the bug still exits: image

Martins3 commented 10 months ago

clear the cache :

rm -r /home/t/.local/share/nvim/mason/staging/

and apply this one

diff --git a/nvim/lua/usr/lsp/mason.lua b/nvim/lua/usr/lsp/mason.lua
index 8d79e98f5374..e9d68e1ee6d7 100644
--- a/nvim/lua/usr/lsp/mason.lua
+++ b/nvim/lua/usr/lsp/mason.lua
@@ -1,7 +1,6 @@
 -- 在 https://github.com/williamboman/mason-lspconfig.nvim 中含有所有支持的 lsp
 local servers = {
   "lua_ls",
-  "nil_ls",
   "cssls",
   "html",
   -- "tsserver",
@@ -39,7 +38,7 @@ if not lspconfig_status_ok then
   return
 end

-local all_servers = {"ccls"}
+local all_servers = {"ccls", "nil_ls"}
 for i = 1, #servers do
   all_servers[#all_servers + 1] = servers[i]
 end
txctxc commented 10 months ago

After applying these change in /nvim/lua/usr/lsp/mason.lua :

-- 在 https://github.com/williamboman/mason-lspconfig.nvim 中含有所有支持的 lsp
  local servers = {
    "lua_ls",
~   -- "nil_ls",
+   -- "rnix",
    "cssls",
    "html",
    -- "tsserver",
    "pyright",
    "rust_analyzer",
    "jsonls",
    "yamlls",
    "efm",
    "vimls",
    "marksman",
  }

local all_servers = {"ccls", "nil_ls"}

and installed nil use nix-env: image

The bug still exits: image

txctxc commented 10 months ago

clear the cache :

rm -r /home/t/.local/share/nvim/mason/staging/

and apply this one

diff --git a/nvim/lua/usr/lsp/mason.lua b/nvim/lua/usr/lsp/mason.lua
index 8d79e98f5374..e9d68e1ee6d7 100644
--- a/nvim/lua/usr/lsp/mason.lua
+++ b/nvim/lua/usr/lsp/mason.lua
@@ -1,7 +1,6 @@
 -- 在 https://github.com/williamboman/mason-lspconfig.nvim 中含有所有支持的 lsp
 local servers = {
   "lua_ls",
-  "nil_ls",
   "cssls",
   "html",
   -- "tsserver",
@@ -39,7 +38,7 @@ if not lspconfig_status_ok then
   return
 end

-local all_servers = {"ccls"}
+local all_servers = {"ccls", "nil_ls"}
 for i = 1, #servers do
   all_servers[#all_servers + 1] = servers[i]
 end

~/.local/share/nvim/mason/staging folder is empty. I do runned rm -r /home/t/.local/share/nvim/mason/staging/ before open Neovim: image

image

Martins3 commented 10 months ago

Fine, I will try this config in a Ubuntu Virtual machine, and rewrite the instructions about installing.