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

ZLS version is too old and breaks randomly

Open acristoffers opened this issue 1 year ago • 3 comments

I've searched open issues for similar requests

Yes

I've manually reviewed logs to find potential errors

Yes

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

  • [X] Yes

Problem description

I was noticing that ZLS was crashing rather randomly on quite simple files (zigtools/zls#838) and when trying to find the cause, I saw that newest master branch does not have this issue. I did not have time yet to test the "randomly" part of the problem, but at least the "LSP's references" features is working properly on the master branch while breaking on the version used by Mason. I don't know how the Mason project select acceptable versions, but given that zig is pre 1.0, the master branches seems to be what people want to have or, at least, some not-so-old nigthly that still compiles fine. Maybe you want to bump the version of ZLS a bit to avoid this randomly-crashing 0.10-dev version you're using as of now?

It may be (and this I have not tested) that the 0.10 version of ZLS only breaks when used with a 0.11 version of ZIG.

Expected behavior

No crashes.

Steps to reproduce

Open a zig file and try to use LSP's find references functionality. The server immediatly crashes. But this is just a way I found to always reproduce it, it also crashes randomly.

Affected packages

zls

Neovim version (>= 0.7)

NVIM v0.8.1 Build type: Release LuaJIT 2.1.0-beta3

Operating system/version

Darwin MacBook-Air-de-Alan.local 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103 arm64 arm Darwin

Healthcheck

mason: require("mason.health").check()
========================================================================
## mason.nvim report
  - OK: neovim version >= 0.7.0
  - OK: **Go**: `go version go1.19.4 darwin/arm64`
  - OK: **cargo**: `cargo 1.68.0-nightly (c994a4a63 2022-12-18)`
  - OK: **luarocks**: `/nix/store/36bv4sp2kcr2ij1hrlb985d9xgvg04i1-luarocks-3.9.1/bin/.luarocks-wrapped 3.9.1`
  - OK: **Ruby**: `ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]`
  - OK: **RubyGem**: `3.3.20`
  - WARNING: **Composer**: not available
  - WARNING: **PHP**: not available
  - OK: **npm**: `9.2.0`
  - OK: **node**: `v18.12.1`
  - OK: **python3**: `Python 3.11.1`
  - OK: **pip3**: `pip 22.3.1 from /Users/alan/.local/share/pip/lib/python3.11/site-packages/pip (python 3.11)`
  - OK: **javac**: `javac 19.0.1`
  - OK: **java**: `openjdk version "19.0.1" 2022-10-18`
  - OK: **julia**: `julia version 1.8.3`
  - OK: **wget**: `GNU Wget 1.21.3 built on darwin21.6.0.`
  - OK: **curl**: `curl 7.86.0 (aarch64-apple-darwin22.1.0) libcurl/7.86.0 OpenSSL/3.0.7 zlib/1.2.13 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.2 libssh2/1.10.0 nghttp2/1.49.0`
  - OK: **gzip**: `Apple gzip 400`
  - OK: **tar**: `tar (GNU tar) 1.34`
  - WARNING: **pwsh**: not available
  - OK: **bash**: `GNU bash, version 3.2.57(1)-release (arm64-apple-darwin22)`
  - OK: **sh**: `Ok`
  - OK: **python3_host_prog**: `Python 3.10.9`
  - WARNING: **python3_host_prog pip**: not available
  - OK: **JAVA_HOME**: `openjdk version "19.0.1" 2022-10-18`
  - OK: GitHub API rate limit. Used: 0. Remaining: 5000. Limit: 5000. Reset: Thu Dec 22 14:56:10 2022.

Screenshots or recordings

No response

acristoffers avatar Dec 22 '22 12:12 acristoffers

Assuming the user has an up-to-date zig version installed in $PATH/%PATH% and that mason has hooks for "update bleeding edge software versions" (bleeding edge is too much of a churn for manual bumping git tags/lockfiles):

The simplest solution is to 1. build from source upon user request, 2. request from the user to provide the zls configuration file and 3. only write the binary + update lock file, if compilation succeeds. The second simplest solution is to require the user to provide the git tag.

That aside, https://github.com/gpanders/ztags or from https://git.sr.ht/~gpanders/ztags should be also packaged for frequent cases, if zls cant resolve a symbol or did not cache the symbols yet (has no offline cache and will very likely not get one, upstream Zig will implement a better one based on compiler info).

The README links no "how to package" or "package guidelines", so I dont understand if binary releases are an requirement or how to deal with "bleeding edge".

matu3ba avatar Dec 26 '22 12:12 matu3ba

Hello! Mason targets the latest release, which as of writing is 0.10.0. As you mentioned, you're using a dev release of zig so probably the latest release of zls is not compatible. Making Mason build from source is currently a non-goal, so it's restricted to what releases are available. You could try building zls from source yourself or alternatively install it via Homebrew if they support it: $ brew install --HEAD zls (again, not sure if zls is available as a brew package).

williamboman avatar Dec 28 '22 19:12 williamboman

My line of thouth was more like "zig is pre-release, so you should use master or nothing, as it is expected to have many breaking changes in every release until 1.0". It's pretty much not ready for production and the developers always makes a point that it isn't. For that reason it makes sense to me to always have bleeding-edge, but maybe I'm a bit too extreme taking the pre-release thing more seriously than I should.

Anyway what bit me was the random breaks because of the versions mismatch. I was thinking maybe a warning could be put somewhere about it, but that should probably go into ZLS. Maybe I should reopen the issue there and propose a line of warning in the logs when the version is a bit too old. It took me some time to realize the versions didn't match.

acristoffers avatar Dec 30 '22 08:12 acristoffers

I see! If you want to install HEAD of zls you'll have to manage it outside of mason.nvim as it targets the latest available release versions.

williamboman avatar Apr 28 '23 10:04 williamboman

On Windows 10 x64:

  1. Run MasonInstall zls from nvim (if you haven't already done so)
  2. Download the latest prebuilt binary from https://github.com/zigtools/zls/wiki/Installation#latest
  3. Copy zls.exe to %USERPROFILE%\AppData\Local\nvim-data\mason\packages\zls\bin

wulfgarpro avatar Dec 03 '23 22:12 wulfgarpro