Match downloaded ZLS version to the installed Zig toolchain - #47
Match downloaded ZLS version to the installed Zig toolchain#47insideable wants to merge 2 commits into
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Vitali Falileev.
|
The extension always fetched the latest zigtools/zls GitHub release regardless of which Zig version was installed. ZLS refuses to run against a mismatched Zig version, so once zls moved ahead of a user's Zig install (e.g. Zig 0.16 while zls was still 0.15) the extension would break with "ZLS 'X' does not support Zig 'Y'" (zed-extensions#36, zed-extensions#38). Detect the Zig version via `zig version` on the worktree's resolved PATH and use zigtools' select-version API to fetch the ZLS build that actually matches it, falling back to the latest release only when no zig binary can be found at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
8807446 to
8a4d795
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @insideable on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @insideable on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
… Zig The version-matching download logic added in the previous commit never ran for users who already had a `zls` binary on PATH (e.g. installed via a system package manager, like Arch's `zls` package), because that case short-circuited before the new logic. Reproduced with pacman's `zls` 0.15.1 alongside Zig 0.16.0: the extension kept handing Zed the outdated system zls, hitting the exact "ZLS 'X' does not support Zig 'Y'" error the previous fix was meant to resolve. Now the PATH shortcut checks that the found zls's major.minor actually matches the detected Zig version (mirroring ZLS's own compatibility rule) before trusting it, falling through to the version-matched download otherwise. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Summary
Fixes #36 and #38.
The extension always fetched the latest
zigtools/zlsGitHub release regardless of which Zig version was actually installed. ZLS refuses to run against a mismatched Zig version, so oncezlsmoved ahead of a user's Zig install (e.g. Zig 0.16 whilezlswas still 0.15), the extension broke with:This also affected dev builds, as reported in #38.
Changes
detect_zig_versionresolveszigvia the worktree's PATH (respecting version managers like mise/asdf that alter the shell env) and runszig versionto get the installed version.matching_zls_releasequeries zigtools'select-versionAPI to fetch the ZLS build that actually matches the installed Zig version, using the API-provided tarball URL directly (handles both the current{arch}-{os}naming and legacy{os}-{arch}naming from older ZLS releases).zigbinary can be found on PATH at all.extension.tomlgains aprocess:execcapability forzig version, required by Zed's WASM sandbox.ZigExtension's binary-path cache is now keyed by detected Zig version (instead of a single global cache), since different worktrees may need different ZLS builds concurrently. Added a bounded cleanup pass that removeszls-*directories no longer referenced by the current session's cache, so this doesn't grow disk usage unboundedly.Test plan
cargo test— 12/12 unit tests passcargo clippy --target wasm32-wasip2 --release— no warningscargo fmt --check— cleancargo build --release --target wasm32-wasip2— builds successfullyzig version→0.16.0, andhttps://releases.zigtools.org/v1/zls/select-version?zig_version=0.16.0&compatibility=only-runtimereturns a matching ZLS 0.16.0 release with a working tarball URL🤖 Generated with Claude Code