Zig Version Manager (zvm) is a tool for managing your Zig installs. With std under heavy development and a large feature roadmap, Zig is bound to continue changing. Breaking existing builds, updating valid syntax, and introducing new features like a package manager. While this is great for developers, it also can lead to headaches when you need multiple versions of a language installed to compile your projects, or a language gets updated frequently.
ZVM lives entirely in $HOME/.zvm on all platforms it supports. Inside of the
directory, ZVM will download new ZIG versions and symlink whichever version you
specify with zvm use to $HOME/.zvm/bin. You should add this folder to your
path. After ZVM 0.2.3, ZVM's installer will now add ZVM to $HOME/.zvm/self.
You should also add this directory as the environment variable ZVM_INSTALL.
The installer scripts should handle this for you automatically on *nix and
Windows systems.
If you don't want to use ZVM_INSTALL (like you already have ZVM in a place you
like), then ZVM will update the exact executable you've called upgrade from.
All installation scripts hosted on www.zvm.app are identical to, and are
automatically synced with their respective copies on GitHub.
www.zvm.app/install.sh === ./install.sh
curl https://www.zvm.app/install.sh | bashirm "https://www.zvm.app/install.ps1" | iexpowershell -c "irm https://www.zvm.app/install.ps1 | iex"go install -ldflags "-s -w" github.com/tristanisham/zvm@latestPlease grab the latest release.
Alternatively, you can build the app by cloning the repository and running
go build .
./zvmIf you want to disable that ZVM can automatically update itself, you can run
go build -tags noAutoUpgrades .instead for building the app.
ZVM requires a few directories to be on your $PATH. If you don't know how to
update your environment variables permanently on Windows, you can follow
this guide. Once you're in
the appropriate menu, add or append to the following environment variables:
Add
- ZVM_INSTALL:
%USERPROFILE%\.zvm\self
Append
- PATH:
%USERPROFILE%\.zvm\bin - PATH:
%ZVM_INSTALL%
It is possible to overwrite the default behavior of ZVM to adhere to XDG
specification on Linux. There's an environment variable ZVM_PATH. Setting it
to $XDG_DATA_HOME/zvm will do the trick.
zvm on the Arch AUR is a
community-maintained package, and may be out of date.
While Zig is still pre-1.0 if you're going to stay up-to-date with the master
branch, you're going to be downloading Zig quite often. You could do it
manually, having to scroll around to find your appropriate version, decompress
it, and install it on your $PATH. Or, you could install ZVM and run
zvm i master every time you want to update. zvm is a static binary under a
permissive license. It supports more platforms than any other Zig version
manager. Its only dependency is tar on Unix-based systems. Whether you're on
Windows, MacOS, Linux, a flavor of BSD, or Plan 9 zvm will let you install,
switch between, and run multiple versions of Zig.
zvm is stable software. Pre-v1.0.0 any breaking changes will be clearly
labeled, and any commands potentially on the chopping block will print notice.
The program is under constant development, and the author is very willing to
work with contributors. If you have any issues, ideas, or contributions you'd
like to suggest
create a GitHub issue.
zvm install <version>
# Or
zvm i <version>Use install or i to download a specific version of Zig. You can pass an
exact version, a shorthand, or an
alias.
zvm i 0.13.0 # Install an exact version
zvm i master # Install the current master nightly
zvm i stable # Install the latest stable release
zvm i .14 # Shorthand — installs 0.14.x (latest patch)You can use abbreviated version numbers and ZVM will resolve them to the latest matching release:
zvm i 0.13 # Installs 0.13.0
zvm i .13 # Same as above — a leading dot implies "0."
zvm i 0.15 # Installs 0.15.2 (latest 0.15.x patch)
zvm i .15 # Same — resolves to 0.15.2Whenever ZVM expands a shorthand, it prints the result so you know exactly what's being fetched:
$ zvm i .14
Resolved ".14" to 0.14.1
...
Shorthand works across every command that takes a version:
zvm i 0.14 # install
zvm use .13 # switch active version
zvm run 0.12 version
zvm rm .11 # uninstallFor use and rm, shorthand is resolved against your locally installed
versions. For install and run, it resolves against the remote version
map.
ZVM understands a few named aliases in addition to concrete versions:
| Alias | Resolves to |
|---|---|
master |
The current master nightly build (passes through as-is) |
stable |
The highest non-dev, non-master release (e.g. 0.16.0) |
zvm i stable # Install the latest stable release
zvm use stable # Switch to the latest installed stable release
zvm i master # Install the current master nightlystable is especially useful in automation — you don't have to know the exact
version number to grab the newest release.
As of v0.7.6 ZVM will now skip downloading a version if it is already
installed. You can always force an install with the --force or -f flag.
zvm i --force masterYou can also enable the old behavior by setting the new alwaysForceInstall
field to true in ~/.zvm/settings.json.
You can now install ZLS with your Zig download! To install ZLS with ZVM, simply
pass the --zls flag with zvm i. For example:
zvm i --zls masterIf you're on a platform where pre-built Zig binaries aren't available for a specific version (e.g., FreeBSD for Zig 0.14.x), you can override the target OS and/or architecture to download a compatible build.
Use the --target-os and --target-arch flags:
zvm i --target-os linux --target-arch x86_64 0.14.0Or set the ZVM_TARGET_OS and ZVM_TARGET_ARCH environment variables:
export ZVM_TARGET_OS=linux
export ZVM_TARGET_ARCH=x86_64
zvm i 0.14.0Both Go-style names (e.g., darwin, amd64) and Zig-style names (e.g.,
macos, x86_64) are accepted.
By default, ZVM will install a ZLS build, which can be used with the given Zig
version, but may not be able to build ZLS from source. If you want to use a ZLS
build, which can be built using the selected Zig version, pass the --full flag
with zvm i --zls. For example:
zvm i --zls --full masterImportant
This does not apply to tagged releases, e.g.: 0.13.0
zvm use <version>Use use to switch between versions of Zig. The version argument accepts
shorthand and aliases.
zvm use master # Switch to master
zvm use stable # Switch to the latest installed stable release
zvm use 0.13 # Resolves to 0.13.x (latest installed patch)
zvm use .14 # Same — leading dot implies "0."# Example
zvm lsUse ls to list all installed version of Zig.
zvm ls --allThe --all flag will list the available versions of Zig for download. Not the
versions locally installed.
zvm ls --vmuThe --vmu flag will list set version maps for Zig and ZLS downloads.
zvm rm 0.10.0 # Remove an exact version
zvm rm .13 # Shorthand — removes the installed 0.13.x
zvm rm stable # Alias — removes the installed stable releaseUse uninstall or rm to remove an installed version from your system.
The version argument accepts shorthand and
aliases, resolved against what you have installed locally.
As of zvm v0.2.3 you can now upgrade your ZVM installation from, well, zvm.
Just run:
zvm upgradeThe latest version of ZVM should install on your machine, regardless of where
your binary lives (though if you have your binary in a privileged folder, you
may have to run this command with sudo).
ZVM (> v0.8.14) can also be built without its auto upgrader (zvm upgrade).
This is to make installing ZVM via a package manager easier for those who prefer
this method.
When you run a build of ZVM with the autoupgrader disabled, you will see a
builder-specified message when you run zvm upgrade.
go build -ldflags=-w -s -X 'main.BuildUpgradeMessage=Command to upgrade ZVM goes here.'Remember, ZVM is an open source project. Anyone can customize and distribute it.
# Example
zvm cleanUse clean to remove build artifacts (Good if you're on Windows).
If you want to run a version of Zig without setting it as your default, the new
run command is your friend. The version argument accepts
shorthand and aliases.
zig version
# 0.13.0
zvm run 0.11.0 version
# 0.11.0
zvm run .12 version # Shorthand works too
# 0.12.1
zvm run stable version # Run against the latest stable
# 0.16.0
zig version
# 0.13.0This can be helpful if you want to test your project on a newer version of Zig without having to switch between bins, or on alternative flavor of Zig.
Make sure you switch your VMU before using run.
zvm vmu zig mach
zvm run mach-latest version
# 0.14.0-dev.1911+3bf89f55cIf you would like to run the currently set Zig, please keep using the standard
zig command.
ZVM lets you choose your vendor for Zig and ZLS. This is great if your company hosts its own internal fork of Zig, you prefer a different flavor of the language, like Mach.
zvm vmu zig "https://machengine.org/zig/index.json" # Change the source ZVM pulls Zig release information from.
zvm vmu zls https://validurl.local/vmu.json
# ZVM only supports schemas that match the offical version map schema.
# Run `vmu default` to reset your version map.
zvm vmu zig default # Resets back to default Zig releases.
zvm vmu zig mach # Sets ZVM to pull from Mach nominated Zig.
zvm vmu zls default # Resets back to default ZLS releases.ZVM now lets you set your own Mirror Distribution Server. If you cannot or choose not to use the official Zig mirror list, you can host your own, or use another grouping of mirrors.
zvm mirrorlist <url>
# Reset to the official mirror
zvm mirrorlist defaultPrint global help information by running:
zvm --helpPrint help information about a specific command or subcommand.
zvm list --helpNAME:
zvm list - list installed Zig versions. Flag `--all` to see remote options
USAGE:
zvm list [command options] [arguments...]
OPTIONS:
--all, -a list remote Zig versions available for download, based on your version map (default: false)
--vmu list set version maps (default: false)
--help, -h show help
zvm --versionPrints the version of ZVM you have installed.
ZVM can emit a completion script for bash, zsh, fish, or pwsh
(PowerShell). The script is generated from ZVM's live command tree, so it
always reflects the commands and flags of the zvm binary you ran it with.
zvm completion bash
zvm completion zsh
zvm completion fish
zvm completion pwshSource the script for the current session:
source <(zvm completion bash)To load it on every new shell, write it to bash-completion's load path:
zvm completion bash > /etc/bash_completion.d/zvm # system-wide
# or for a single user:
zvm completion bash > ~/.local/share/bash-completion/completions/zvmPlace the script somewhere on your $fpath as _zvm. Pick a user-writable
directory so you don't need sudo:
# Plain zsh — create a user completions dir and add it to $fpath in ~/.zshrc:
mkdir -p ~/.zsh/completions
zvm completion zsh > ~/.zsh/completions/_zvm
# Then in ~/.zshrc (before `compinit`):
fpath=(~/.zsh/completions $fpath)If you use Oh My Zsh, drop it into the custom completions
directory instead — Oh My Zsh adds it to $fpath automatically:
mkdir -p ~/.oh-my-zsh/custom/completions
zvm completion zsh > ~/.oh-my-zsh/custom/completions/_zvmThen ensure compinit is running in your ~/.zshrc (Oh My Zsh already does
this for you):
autoload -Uz compinit && compinitzvm completion fish > ~/.config/fish/completions/zvm.fishFish picks this up automatically on the next shell.
zvm completion pwsh > $HOME/.zvm/zvm.ps1Then dot-source the file from your PowerShell profile ($PROFILE):
. "$HOME/.zvm/zvm.ps1"Enable or disable colored ZVM output. No value toggles colors.
- on
- yes/y
- enabled
- true
- off
- no/n
- disabled
- false
--color # Toggle ANSI color printing on or off for ZVM's output, i.e. --color=trueZVM_DEBUGenables DEBUG logging for your executable. This is meant for contributors and developers.ZVM_SET_CUToggle the automatic upgrade checker. If you want to reenable the checker, justunset ZVM_SET_CU.ZVM_PATHreplaces the default install location for ZVM Set the environment variable to the parent directory of where you've placed the.zvmdirectory.ZVM_TARGET_OSOverride the target operating system for downloads (e.g.,linux,macos,windows,freebsd). Useful on platforms where Zig doesn't provide pre-built binaries for a specific version.ZVM_TARGET_ARCHOverride the target architecture for downloads (e.g.,x86_64,aarch64,arm,riscv64).ZVM_SKIP_TLS_VERIFYDo you have problems using TLS in your environment? Toggle off verifying TLS by setting this environment variable.- By default when this is enabled ZVM will print a warning. Set this variable
to
no-warnto silence this warning.
- By default when this is enabled ZVM will print a warning. Set this variable
to
ZVM has additional setting stored in ~/.zvm/settings.json. You can manually
update version maps, toggle color support, and disable the automatic upgrade
checker here. All settings are also exposed as flags or environment variables.
This file is stateful, and ZVM will create it if it does not exist and utilizes
it for its operation.
