Software Development Simplified

How to Install Zig on Debian: The Easy Way with debian.griffo.io

By Dario on Jul 28, 2025
Zig Programming Language Installation on Debian

How to Install Zig on Debian: The Easy Way with debian.griffo.io

Zig is a general-purpose programming language and toolchain designed for maintaining robust, optimal, and reusable software. While Zig is gaining popularity among developers for its performance and safety features, installing it on Debian systems can be challenging since it’s not available in the official Debian repositories.

Fortunately, there’s an easier way: using the unofficial debian.griffo.io repository, which provides pre-built Debian packages for Zig and many other useful development tools.

Why Use debian.griffo.io?

The debian.griffo.io repository offers several advantages over manual installation:

  • Easy installation and updates through APT package manager
  • Both stable and nightly builds available
  • Automatic dependency management
  • Consistent with Debian packaging standards
  • Supports multiple Debian distributions (Bookworm, Trixie, Sid)

Prerequisites

Before we begin, make sure you have:

  • A Debian-based system (Bookworm, Trixie, or Sid)
  • sudo privileges
  • curl installed (install with sudo apt install curl if needed)

Step 1: Add the Repository

First, we need to add the GPG key and repository to your system. Run the following commands in your terminal:

# Add the GPG key
curl -sS https://debian.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/debian.griffo.io.gpg

# Add the repository
echo "deb https://debian.griffo.io/apt $(lsb_release -sc 2>/dev/null) main" | sudo tee /etc/apt/sources.list.d/debian.griffo.io.list

Let’s break down what these commands do:

  1. GPG Key Addition: Downloads and installs the repository’s GPG key, which ensures the authenticity of the packages
  2. Repository Addition: Adds the repository URL to your APT sources list, automatically detecting your Debian distribution

Step 2: Update Package Lists

After adding the repository, update your package lists:

sudo apt update

Step 3: Install Zig

Now you can install Zig using APT. The repository provides multiple options and allows you to install different versions simultaneously:

Understanding Zig Package Structure

The repository uses a smart packaging approach:

  • zig - A metapackage that points to zig-0 (the stable release)
  • zig-0 - The actual stable Zig package
  • zig-master - Weekly builds from the master branch (cutting-edge features)

This design allows you to install multiple versions of Zig side by side without conflicts.

Install Stable Zig

For the stable release of Zig:

sudo apt install zig

This installs the zig metapackage, which automatically pulls in zig-0 (the stable version).

Install Weekly Builds

For the latest weekly builds from the master branch:

sudo apt install zig-master

Install Both Versions

You can install both stable and weekly builds simultaneously:

sudo apt install zig zig-master

This gives you access to both versions on the same system. The system uses Debian’s update-alternatives mechanism to manage which version is active when you run the zig command, allowing you to:

  • Switch between stable and weekly builds easily
  • Use different versions for different projects
  • Compare behavior between versions

Step 4: Verify Installation

After installation, verify that Zig is working correctly:

zig version

You should see output similar to:

0.14.1

Or if you have the weekly build active:

0.14.0-dev.1911+3bf89f55c

Step 5: Managing Multiple Versions with update-alternatives

When you have both versions installed, Debian’s update-alternatives system manages which version is active when you run the zig command.

Check Available Versions

To see which Zig versions are available and which one is currently active:

update-alternatives --config zig

This will show output similar to:

There are 2 choices for the alternative zig (providing /usr/bin/zig).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/lib/zig/0.14.1/zig      100       auto mode
  1            /usr/lib/zig/0.14.1/zig      100       manual mode
  2            /usr/lib/zig/master/zig      50        manual mode

Press <enter> to keep the current choice[*], or type selection number:

Switch Between Versions

To switch to a different version, run the command above and enter the selection number for your desired version. For example, entering 2 would switch to the weekly build.

Bonus: Installing ZLS (Zig Language Server)

The repository also provides ZLS, the Language Server Protocol implementation for Zig, which enables IDE features in your editor. Like Zig, ZLS follows the same versioning pattern and uses update-alternatives:

Stable ZLS

sudo apt install zls

This installs ZLS that works with the stable Zig version.

Weekly ZLS

sudo apt install zls-master

This installs ZLS that works with the weekly Zig builds.

Install Both ZLS Versions

You can install both versions to match your Zig installations:

sudo apt install zls zls-master

Managing ZLS Versions

Like Zig, ZLS uses update-alternatives to manage multiple versions:

# Check available ZLS versions
update-alternatives --config zls

# Switch to stable ZLS
sudo update-alternatives --config zls

This ensures you have the appropriate language server for whichever Zig version you’re currently using.

Updating Zig

One of the biggest advantages of using the repository is easy updates. To update Zig (and all other packages):

sudo apt update && sudo apt upgrade

Other Available Packages

The debian.griffo.io repository doesn’t just provide Zig. It also includes many other useful development tools:

  • lazydocker: Terminal UI for Docker
  • lazygit: Terminal UI for Git
  • yazi: Terminal file manager written in Rust
  • fzf: Command-line fuzzy finder
  • uv: Fast Python package manager (installation guide)
  • ghostty: Fast terminal emulator
  • And many more!

Troubleshooting

Repository Key Issues

If you encounter GPG key issues, make sure you’re using the correct key. The repository updated its public key on March 4th, 2025, so older installations might need to update:

# Remove old key if it exists
sudo rm -f /etc/apt/trusted.gpg.d/debian.griffo.io.gpg

# Add the new key
curl -sS https://debian.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/debian.griffo.io.gpg

Package Not Found

If APT can’t find the Zig package:

  1. Ensure you’ve run sudo apt update after adding the repository
  2. Check that your Debian distribution is supported (Bookworm, Trixie, or Sid)
  3. Verify the repository was added correctly: cat /etc/apt/sources.list.d/debian.griffo.io.list

Uninstalling

If you need to remove Zig, you have several options depending on what you want to remove:

Remove Specific Versions

# Remove stable Zig (metapackage)
sudo apt remove zig

# Remove the actual stable package
sudo apt remove zig-0

# Remove weekly builds
sudo apt remove zig-master

# Remove all Zig versions
sudo apt remove zig zig-0 zig-master

Remove ZLS

# Remove stable ZLS
sudo apt remove zls

# Remove weekly ZLS
sudo apt remove zls-master

# Remove all ZLS versions
sudo apt remove zls zls-master

Remove the Repository (Optional)

If you want to completely remove the repository:

sudo rm /etc/apt/sources.list.d/debian.griffo.io.list
sudo rm /etc/apt/trusted.gpg.d/debian.griffo.io.gpg
sudo apt update

Building Your First Zig Program

Now that Zig is installed, let’s create a simple “Hello, World!” program:

# Create a new file
echo 'const std = @import("std");

pub fn main() void {
    std.debug.print("Hello, World!\\n", .{});
}' > hello.zig

Compile and Run with Different Versions

You can test your program by switching between versions:

# Compile and run with current active version
zig run hello.zig

# Switch to weekly build and run
sudo update-alternatives --set zig /usr/bin/zig-master
zig run hello.zig

# Switch back to stable and run
sudo update-alternatives --set zig /usr/bin/zig-0.14.1
zig run hello.zig

All versions should output:

Hello, World!

Version-Specific Projects

For larger projects, you can switch versions as needed:

# Create a project directory
mkdir my-project
cd my-project

# Use stable Zig for this project
sudo update-alternatives --set zig /usr/bin/zig-0.14.1
zig init-exe

# Later, switch to weekly build to test new features
sudo update-alternatives --set zig /usr/bin/zig-master
zig build

Conclusion

Installing Zig on Debian doesn’t have to be complicated. The debian.griffo.io repository provides an easy, maintainable way to install and keep Zig up-to-date on your Debian system. The smart packaging approach with metapackages and update-alternatives allows you to:

  • Install multiple versions simultaneously without conflicts
  • Switch between stable and weekly builds using update-alternatives --config zig
  • Use the same zig command regardless of which version is active
  • Easily manage versions through Debian’s standard alternatives system
  • Keep both versions updated through the standard APT workflow

Whether you need the stable release for production work or the weekly builds for experimenting with the latest features, this repository has you covered. The update-alternatives system makes it seamless to switch between versions, perfect for developers who want to stay current with Zig’s development while maintaining stability for their projects.

The repository is maintained as an unofficial community project and provides packages that aren’t available in the official Debian repositories. It’s a valuable resource for Debian users who want access to modern development tools without the hassle of manual compilation and installation.

If you’re working with Python projects, you might also be interested in our guide on How to Install uv on Debian, which covers installing the extremely fast Python package manager using the same repository and installation process.

Happy coding with Zig!

Resources


Disclaimer: The debian.griffo.io repository is an unofficial community project and is not affiliated with the official Debian project or the Zig programming language team.

Twitter iconLinkedIn iconGitHub iconYouTube icon
© 2025 Dario Griffo. All rights reserved.