Skip to content

Ziglang - /lsp-examples/zig/python3 ./install.py = subprocess.CalledProcessError: Command '[zig, 'build', '-Drelease-safe']' returned non-zero exit status 1. #45

@arnoldmashava

Description

@arnoldmashava

The existing /lsp-examples/zig/install.py script for the setting up and configuration of the zls is resulting in an incomplete build automation process, through the specified zig build command:

...
subprocess.check_call( [ zig, 'build', '-Drelease-safe'])
...
  1. Activities and Observations
 [ master {origin/master} ↓·16 | …1 ]
✔ 12:32 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig $ python3 ./install.py
Building zig lsp from source  https://github.com/zigtools/zls
zls alread cloned into directory
Going to update and upgrade
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 44 (delta 30), reused 31 (delta 23), pack-reused 0 (from 0)
Unpacking objects: 100% (44/44), 14.17 KiB | 113.00 KiB/s, done.
From https://github.com/zigtools/zls
   360bd96..188a4c0  master     -> origin/master
Updating 360bd96..188a4c0
Fast-forward
 .github/workflows/coverage.yml |   2 +-
 build.zig                      |  51 +++++++++++++++++++++++----------
 src/Server.zig                 |  23 +++++++++++----
 src/analyser/string_pool.zig   |   1 +
 src/analysis.zig               | 158 ++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------
 src/features/completions.zig   |   8 +++---
 src/zls.zig                    |   1 +
 tests/add_analysis_cases.zig   |  47 ++++++++++++++++++++++++++++++
 tests/analysis/array.zig       |  81 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/analysis/basic.zig       |  48 +++++++++++++++++++++++++++++++
 tests/analysis/optional.zig    |  20 +++++++++++++
 tests/analysis/pointer.zig     | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/analysis_check.zig       | 270 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/helper.zig               | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 14 files changed, 905 insertions(+), 117 deletions(-)
 create mode 100644 tests/add_analysis_cases.zig
 create mode 100644 tests/analysis/array.zig
 create mode 100644 tests/analysis/basic.zig
 create mode 100644 tests/analysis/optional.zig
 create mode 100644 tests/analysis/pointer.zig
 create mode 100644 tests/analysis_check.zig
warning: Failed to run git describe to resolve ZLS version: error.ExitCodeFailure
command: git -C /home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls describe --match *.*.* --tags

Consider passing the -Dversion-string flag to specify the ZLS version.
  1. Error(s)
error: invalid option: -Drelease-safe
error:   access the help menu with 'zig build -h'
error: the following build command failed with exit code 1:
/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache/o/17b7ac76a490393e5cd989b5ec5e9ee7/build /opt/zig-linux-x86_64/zig /opt/zig-linux-x86_64/lib /home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls /home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache /home/Arnold.Mashava/.cache/zig --seed 0xb198334a -Z9379235df8ba9750 -Drelease-safe
Traceback (most recent call last):
  File "/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/./install.py", line 71, in <module>
    Main()
  File "/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/./install.py", line 67, in Main
    subprocess.check_call( [ zig, 'build', '-Drelease-safe'])
  File "/usr/lib64/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/zig-linux-x86_64/zig', 'build', '-Drelease-safe']' returned non-zero exit status 1.
  1. Hypothetical Resolution(s) from Trial and Error

From the README.md Documentation, the methodology for building from source specifies the -Doptimize=ReleaseSafe flag

zig build -Doptimize=ReleaseSafe

Which if incorporated into the /lsp-examples/zig/install.py script

...
subprocess.check_call( [ zig, 'build', '-Doptimize=ReleaseSafe'])
...

still throws back some errors

✔ 12:49 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig $ python3 ./install.py 
Building zig lsp from source  https://github.com/zigtools/zls
zls alread cloned into directory
Going to update and upgrade
Already up to date.
warning: Failed to run git describe to resolve ZLS version: error.ExitCodeFailure
command: git -C /home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls describe --match *.*.* --tags

Consider passing the -Dversion-string flag to specify the ZLS version.

From the invocation of zig build --help, the -Dversion-string flag is described as

-Dversion-string=[string]    Override the version of this build. Must be a semantic version.

The unknown in my case, was the correct versioning and tagging of zls, which from source code Releases and Tags, the latest release of the zls is tagged as zls 0.13.0 and this outdated version was outrightly rejected as inadmissible by the build automation process

...
subprocess.check_call( [ zig, 'build', '-Doptimize=ReleaseSafe', '-Dversion-string=0.13.0'])
...

The rejection of my moves, stunts and advances

 [ master {origin/master} | ✚ 1 …2 ]
✘ 13:00 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig $ python3 ./install.py 
Building zig lsp from source  https://github.com/zigtools/zls
zls alread cloned into directory
Going to update and upgrade
Already up to date.
install
└─ install zls
   └─ zig build-exe zls ReleaseSafe native 1 errors
/opt/zig-linux-x86_64/lib/std/debug.zig:518:14: error: reached unreachable code
    if (!ok) unreachable; // assertion failure
             ^~~~~~~~~~~
src/build_runner/BuildRunnerVersion.zig:22:38: note: called from here
            comptime std.debug.assert(!@hasField(BuildRunnerVersion, "master"));
                     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: the following command failed with 1 compilation errors:
/opt/zig-linux-x86_64/zig build-exe -OReleaseSafe --dep exe_options --dep known-folders --dep tracy --dep zls -Mroot=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/src/main.zig -Mexe_options=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache/c/b437bdce5ab85f0eb7198dff0d1383d2/options.zig -ODebug -Mknown-folders=/home/Arnold.Mashava/.cache/zig/p/12205f5e7505c96573f6fc5144592ec38942fb0a326d692f9cddc0c7dd38f9028f29/known-folders.zig -OReleaseSafe --dep options -Mtracy=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/src/tracy.zig -OReleaseSafe --dep known-folders --dep diffz --dep lsp --dep tracy --dep build_options --dep version_data -Mzls=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/src/zls.zig -Moptions=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache/c/c9f8dc856aaed12d36cccd9f080cf848/options.zig -Mdiffz=/home/Arnold.Mashava/.cache/zig/p/1220102cb2c669d82184fb1dc5380193d37d68b54e8d75b76b2d155b9af7d7e2e76d/DiffMatchPatch.zig -ODebug --dep parser --dep types -Mlsp=/home/Arnold.Mashava/.cache/zig/p/12208e12a10e78de19f140acae65e6edc20189459dd208d5f6b7afdf0aa894113d1b/src/lsp.zig -Mbuild_options=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache/c/3ded8bd6de80d06fe77f8140dc2c3429/options.zig -Mversion_data=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache/o/a752b1e1896348aa17260fc15d4fcbaa/version_data.zig -Mparser=/home/Arnold.Mashava/.cache/zig/p/12208e12a10e78de19f140acae65e6edc20189459dd208d5f6b7afdf0aa894113d1b/src/parser.zig --dep parser -Mtypes=/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache/o/fb543e03e469422576d8eaa94b83e291/lsp_types.zig --cache-dir /home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache --global-cache-dir /home/Arnold.Mashava/.cache/zig --name zls --zig-lib-dir /opt/zig-linux-x86_64/lib/ --listen=- 
Build Summary: 7/10 steps succeeded; 1 failed
install transitive failure
└─ install zls transitive failure
   └─ zig build-exe zls ReleaseSafe native 1 errors
error: the following build command failed with exit code 1:
/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache/o/17b7ac76a490393e5cd989b5ec5e9ee7/build /opt/zig-linux-x86_64/zig /opt/zig-linux-x86_64/lib /home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls /home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/zls/.zig-cache /home/Arnold.Mashava/.cache/zig --seed 0x34095c49 -Z5993479b690b54cb -Doptimize=ReleaseSafe -Dversion-string=0.13.0
Traceback (most recent call last):
  File "/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/./install.py", line 71, in <module>
    Main()
  File "/home/Arnold.Mashava/.vim/plugged/lsp-examples/zig/./install.py", line 68, in Main
    subprocess.check_call( [ zig, 'build', '-Doptimize=ReleaseSafe', '-Dversion-string=0.13.0'])
  File "/usr/lib64/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/zig-linux-x86_64/zig', 'build', '-Doptimize=ReleaseSafe', '-Dversion-string=0.13.0']' returned non-zero exit status 1.

and this was somewhat predictable, because of the incompatibility with the version of the Ziglang environment that was being reported by my zig compiler

 [ master {origin/master} | ✚ 1 …2 ]
✔ 13:05 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig $ zig env
{
 "zig_exe": "/opt/zig-linux-x86_64/zig",
 "lib_dir": "/opt/zig-linux-x86_64/lib",
 "std_dir": "/opt/zig-linux-x86_64/lib/std",
 "global_cache_dir": "/home/Arnold.Mashava/.cache/zig",
 "version": "0.14.0-dev.3222+8a3aebaee",
 "target": "x86_64-linux.6.4.9...6.4.9-gnu.2.39",
 "env": {
  "ZIG_GLOBAL_CACHE_DIR": null,
  "ZIG_LOCAL_CACHE_DIR": null,
  "ZIG_LIB_DIR": null,
  "ZIG_LIBC": null,
  "ZIG_BUILD_RUNNER": null,
  "ZIG_VERBOSE_LINK": null,
  "ZIG_VERBOSE_CC": null,
  "ZIG_BTRFS_WORKAROUND": null,
  "ZIG_DEBUG_CMD": null,
  "CC": null,
  "NO_COLOR": null,
  "CLICOLOR_FORCE": null,
  "XDG_CACHE_HOME": "/home/Arnold.Mashava/.cache",
  "HOME": "/home/Arnold.Mashava"
 }
}

¡Ouch!

Through a separate and standalone zls source code directory

 [ master {origin/master} | ✔  ]
✔ 13:20 Arnold.Mashava@localhost /opt/zls $ zig build -Doptimize=ReleaseSafe
 [ master {origin/master} | ✔  ]
✔ 13:23 Arnold.Mashava@localhost /opt/zls/zig-out/bin $ ls -FXAlv
.rwxr-xr-x Arnold.Mashava Arnold.Mashava 16 MB Sat Feb 15 13:22:54 2025 zls*
 [ master {origin/master} | ✔  ]
✔ 13:23 Arnold.Mashava@localhost /opt/zls/zig-out/bin $ ./zls env
{
 "version": "0.14.0-dev.390+188a4c04",
 "global_cache_dir": "/home/Arnold.Mashava/.cache/zls",
 "global_config_dir": "/home/Arnold.Mashava/.config/kdedefaults",
 "local_config_dir": "/home/Arnold.Mashava/.config",
 "config_file": "/home/Arnold.Mashava/.config/zls.json",
 "log_file": "/home/Arnold.Mashava/.cache/zls/zls.log"
}

Assigning this newly built version 0.14.0-dev.390+188a4c04 to the Dversion-string flag in the /lsp-examples/zig/install.py script

...
subprocess.check_call( [ zig, 'build', '-Doptimize=ReleaseSafe', '-Dversion-string=0.14.0-dev.390+188a4c04'])
...

and initiating the build automation process again

 [ master {origin/master} | ✚ 1 …2 ]
✔ 13:37 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig $ python3 ./install.py
Building zig lsp from source  https://github.com/zigtools/zls
zls alread cloned into directory
Going to update and upgrade
Already up to date.

¡Voilà!

That mouthful of a version number, 0.14.0-dev.390+188a4c04, was surely obvious, ¿wasn't it?

A few final verification checks

 [ master {origin/master} | ✔  ]
✔ 13:40 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig/zls/zig-out/bin $ ls -FXAlv
.rwxr-xr-x Arnold.Mashava Arnold.Mashava 16 MB Sat Feb 15 13:33:46 2025 zls*
 [ master {origin/master} | ✔  ]
✔ 13:42 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig/zls/zig-out/bin $ ./zls env
{
 "version": "0.14.0-dev.390+188a4c04",
 "global_cache_dir": "/home/Arnold.Mashava/.cache/zls",
 "global_config_dir": "/home/Arnold.Mashava/.config/kdedefaults",
 "local_config_dir": "/home/Arnold.Mashava/.config",
 "config_file": "/home/Arnold.Mashava/.config/zls.json",
 "log_file": "/home/Arnold.Mashava/.cache/zls/zls.log"
}

and the final act

 [ master {origin/master} | ✔  ]
✔ 13:55 Arnold.Mashava@localhost ~/.vim/plugged/lsp-examples/zig/zls/zig-out/bin $ ./zls
warn  ( main ): ZLS is not a CLI tool, it communicates over the Language Server Protocol.
warn  ( main ): Did you mean to run 'zls --help'?
warn  ( main ): 
Content-Length: 130

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Starting ZLS      0.14.0-dev.390+188a4c04 @ './zls'"}}Content-Length: 143

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Log File:         /home/Arnold.Mashava/.cache/zls/zls.log (info)"}}
  1. Epilogue

The declaration of the Dversion-string flag in the /lsp-examples/zig/install.py script is somewhat not an exact science, as long as the semantic versioning of the zls is not updated and specified in the source code Releases and Tags - where the current one that is being presented is an untidy damp squib.

However for the sake of continuity, in as much as this Rastafarian hack is not salacious enough and easy on the Wandering Eye, I will still forge ahead and invoke a provisional Pull Request, that will provide a provisional resolution to this Issue, which hopefully will bring some finality in the interim.

To the godfathers of Asynchronous Code Completion in Vim and Neovim - @Valloric, @Zverik, et al.

>_ sudo ¡Muchas Gracias! --verbosity=debug --syntax=sh

Saludos Cordiales,

Rastafari.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions