Vendoring the Zig compiler

14 April 2026

workflow

One of the things I appreciate most about Zig is how it tries to avoid dependencies. By default, the compiler outputs executables with no dependency on system libraries (when possible), the standard library doesn't depend on libc, and the package manager has no central repository and can fetch arbitrary URLs and git repos.

This even extends to the compiler itself!

stratts@server ~/p/n/zig (master)> ldd zig
        not a dynamic executable

The suggested method to install Zig is to just... extract the archive wherever you want.

To that end, I've started favouring a pattern where I "vendor" the Zig compiler in my project directory, by extracting it into a .zig folder, then creating a zig symlink in the project root to .zig/zig.

Which means no global installation, and no version mismatch - each project gets exactly the Zig version that it needs.

At "only" 150MB, the compiler is smaller than many node_modules directories. Bearing in mind that it has the ability to cross compile to any of Zig's many supported targets.

Instead of committing the compiler itself to the repo, I have a get-zig.sh script along the lines of:

#!/bin/bash
ZIG_VERSION="0.15.1"
ARCH_OS="x86_64-linux"

TMP_DIR=$(mktemp -d)
wget "https://ziglang.org/download/$ZIG_VERSION/zig-$ARCH_OS-$ZIG_VERSION.tar.xz" \
-O "$TMP_DIR/zig.tar.xz"
tar -xf "$TMP_DIR/zig.tar.xz"
rm -r "$TMP_DIR"
rm -rf .zig
mv "zig-$ARCH_OS-$ZIG_VERSION" .zig
rm zig
ln -s .zig/zig zig

The end result of this is that I have old projects built using Zig versions as far back as 0.8.0 that still build today - because everything required is contained within the project directory.

Granted - this is partly a unique problem to Zig, as it's a pre-release language being rapidly developed. But some of my C# and Java projects that are a challenge to get building, as they depended on a specific version of the toolkit, compiler, or even the IDE. So I find the simplicity of this to be extremely cool.