zv (zig version) manager
zv is a blazing-fast, cross-platform, simple-to-use compiler toolchain manager for Zig, written in Rust. zv aims to be a fast and dependable manager for Zig and ZLS, both system-wide and project-specific, with either inline syntax zig +<version> or by using a .zigversion file in your project root. A version can be a semver, master, or latest for the latest stable. These values are fetched from the cached Ziglang download index available at Zig official index.
With zv binaries, you can now build with the master branch without changing your default system Zig version:
Caching is built-in, so you never have to wait any longer than strictly necessary.
You can also specify a version number, e.g., zig +0.15.1. With zv, you also have the option of pinning per-project Zig versions using a .zigversion file, which takes the same format as + would for inline Zig commands. You can have a project with these contents:
# file .zigversion
0.15.1
which will always use version 0.15.1 when you run any zig command inside it. How cool is that?
It also doubles as a project template starter, providing multiple variants of a Zig project, from a barebones template with a very trimmed-down build.zig and main.zig file, or the standard Zig project template. Find out more with zv init --help.
zv prefers community mirrors for downloads, as that's the official recommendation, with minisign and shasum verification done before any toolchain is installed.
Installation
Quick install script (Recommended):
Linux/macOS:
|
Windows (PowerShell):
irm https://github.com/weezy20/zv/releases/latest/download/zv-installer.ps1 | iex
HomeBrew:
NPM:
Step 1: Install the binary from crates.io or build from source
Using cargo install:
# From crates.io
# OR from GitHub
Or build from source (clone the repo first):
# Build release binary (creates target/release/zv)
Step 2: Preview setup changes (optional but recommended)
Using cargo installed binary:
# OR shorthand:
Or from source:
# OR shorthand:
Step 3: Run setup to install zv to ZV_DIR/bin and configure your shell
Using cargo installed binary:
Or from source:
# or if you already have ZV_DIR/bin in path
This self-installs zv to ZV_DIR/bin (default: $HOME/.zv/bin on Unix, %USERPROFILE%\.zv\bin on Windows) and adds it to your PATH.
Step 4: Remove the cargo binary (optional cleanup - only if you used cargo install)
From now on, use the zv installed in ZV_DIR/bin.
Note: Run
zv setupafter installation to self-installzvtoZV_DIR/bin(default:$HOME/.zv/binon Unix,%USERPROFILE%\.zv\binon Windows). Without this step you might not expectzvto work correctly because the installer scripts do not downloadzvtoZV_DIR/binat the moment.
Updating zv
If you have the repo cloned or are using cargo-installed binary:
# Builds new version and simultaneously runs setup to update the binary in ZV_DIR/bin
# Or you can also use sync
If you have the quick install script you should have a zv-update command available:
If you used zv-update your ZV_DIR/bin/zv might still be on the older version. Just run zv setup or zv sync with the newer bin to update the binary in ZV_DIR/bin.
This replaces your existing ZV_DIR/bin/zv installation. This is not strictly necessary but recommeneded to keep your ZV_DIR/bin/zv binary up to date.
Usage
All zv data lives in ZV_DIR, including Zig versions, downloads, cache files, and the zv binary itself.
Default locations:
- Unix/Linux/macOS:
$HOME/.zv - Windows:
%USERPROFILE%\.zv
You can customize this by setting the ZV_DIR environment variable.
Use zv for project creation:
|
Use zv as your Zig compiler toolchain manager:
# Version selection - basic usage
# pass in -f or --force-ziglang to download using `ziglang.org` instead of community mirrors (default & recommended)
| | |
# Per-project Zig config
# Management commands
| | | |
minisign verification is done using jedisct1/rust-minisign-verify — a small minisign library in pure Rust.
It also supports NO_COLOR for non-TTY environments.
I hope you enjoy using it! ♥
Customizing ZV behaviour:
🔧 Environment Variables for customizing zv
| Variable | Description | Default / Notes |
|---|---|---|
ZV_LOG |
Sets the log level (same as RUST_LOG). If set, logging follows the specified level. |
Inherits RUST_LOG behavior |
ZV_DIR |
Defines the home directory for zv. |
Default $HOME/.zv for linux/macos or unix. For windows it usually will be %USERPROFILE%/.zv |
ZV_INDEX_TTL_DAYS |
Number of days between automatic index syncs. | 21 days — Using master or latest in inline mode use a shorter cache duration of just 1 day unlike use which will always fetch master & latest from network, so practically, you never have to worry about setting this variable yourself. |
ZV_MIRRORS_TTL_DAYS |
Number of days before refreshing the mirrors list. Broken mirrors degrade automatically. Use zv sync to force refresh. |
21 days — mirrors and index can be resynced immediately with zv sync. master relies on latest builds & so does latest and some community mirrors may not have it available; zv will retry other mirrors in that case. |
NO_COLOR |
If set, disables color output in all zv commands. | No color output; useful for non-TTY environments or scripts. |
ZV_FETCH_TIMEOUT_SECS |
Request timeout to use for network operations requiring fetching index/mirrors list from ziglang.org. |
Default 15 seconds for most operations. |
Tips:
-
If you prefer some mirrors to others, you can put it as
rank = 1on your preferred mirrors (Default is rank 1 for all mirros) or lower the rank of mirrors that you don't want.rankis a range from 1..255, lower is better and more preferred when doing random selection. The mirrors file is generated at<ZV_DIR>/mirrors.toml -
Currently
zv use masterwill only install the master as present in zig-index. This means that older master installations still remain under the masters folder and can be selected viazv use master@<older master version>which can be obtained viazv ls. Note, installing older master versions like this doesn't work because formasterwe exclusively consult the information in the zig-index. However, there's no reason this can't be supported in the future with a separatedev@<version>syntax.