Skip to content

fix: resolve underlying Zig version for Mach builds in anyzls#80

Draft
kimjune01 wants to merge 2 commits into
marler8997:masterfrom
kimjune01:fix-zls-mach-version
Draft

fix: resolve underlying Zig version for Mach builds in anyzls#80
kimjune01 wants to merge 2 commits into
marler8997:masterfrom
kimjune01:fix-zls-mach-version

Conversation

@kimjune01

Copy link
Copy Markdown

Summary

  • Fix crash when anyzls encounters Mach Zig version strings by resolving the underlying Zig version from the index metadata
  • Mach versions (e.g., 0.14.0-dev.3163+0) are not valid semver for ZLS compatibility checks; the fix maps them to their base Zig release version

Fixes #73

Test plan

  • anyzls no longer crashes when encountering Mach version strings
  • Standard semver versions continue to work unchanged

kimjune01 added 2 commits May 11, 2026 21:13
ZLS doesn't provide Mach-versioned releases. When running zls with
a Mach Zig version (e.g., 2024.11.0-mach), anyzig would try to
download a non-existent ZLS binary with the -mach suffix, resulting
in a 404 error.

This fix strips the -mach suffix from the version when building the
ZLS download URL, allowing it to download the correct base version
(e.g., 2024.11.0).

Fixes marler8997#73
The original stripMachVersion approach was incorrect -- stripping the
-mach suffix from e.g. "2024.11.0-mach" yields "2024.11.0", which is
a Mach release number, not a valid ZLS version. ZLS doesn't publish
builds for Mach version numbers.

Instead, look up the Mach download index to resolve the underlying Zig
version (e.g. 2024.11.0-mach -> 0.14.0-dev.2577+271452d22), and use
that real Zig version for the ZLS URL. This mirrors how the Zig binary
path already handles Mach versions via extractUrlFromMachDownloadIndex.

Fixes marler8997#73
@kimjune01 kimjune01 marked this pull request as draft May 18, 2026 03:49
@kimjune01

Copy link
Copy Markdown
Author

Human here. Unfortunate news: I'm moving this into drafts because my current setup uses Zig 0.16 and the build.zig.zon hash format here was authored against an older Zig — I get "invalid hash: incomplete" trying to build locally. I'd need to pin a specific Zig version to validate this fix and I don't have that set up cleanly right now. I wish I could've taken it to completion. Thanks for understanding.

@Verafahn

Verafahn commented May 29, 2026

Copy link
Copy Markdown
Language server zls:

initializing server zls, id 1: Server reset the connection
-- stderr --
anyzig: .mach_zig_version '2026.4.10-mach' pulled from 'E:\Zig\learn-mach\mymach\build.zig.zon'
anyzig: appdata 'C:\Users\lenovo\AppData\Local\anyzig'
anyzig: downloading 'https://builds.zigtools.org/zls-x86_64-windows-0.16.0-dev.3142+5ccfeb926.zip'...
error: bad HTTP response code: '404 Not Found'

The version number format of ZLS is not exactly the same as Zig.

For 2026.4.10-mach. Zig's version number is 0.16.0-dev.3142+5ccfeb926, while ZLS's version number is 0.16.0-dev.300+f391142c.

Perhaps the corresponding version number of ZLS can be obtained by crawling data from https://zigtools.org/zls/?zig_version=<zig version>&compatibility=only-runtime.

@Verafahn

Verafahn commented Jun 4, 2026

Copy link
Copy Markdown

The API that can be used to request ZLS version is https://releases.zigtools.org/v1/zls/select-version?zig_version=0.16.0&compatibility=only-runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

anyzls does not work with Mach Zig versions

2 participants