Error: "command terminated unexpectedly"

I wrote a hello world zig file.

const std: type = @import("std");

pub fn main() void {
    std.debug.print("{s}\n", .{"Hello World"});

[Yes this is the whole file]. When I zig build run I get this message:

└─ run freightdb
   └─ zig build-exe freightdb Debug native failure
error: the following command terminated unexpectedly:
/nix/store/n146fdz4qp6flryj8bw8bqly0q8mg18j-zig-0.12.0-dev.3434+e90583f5d/bin/zig build-exe -ODebug --dep ziggy -Mroot=/home/cyrilguiz/.codeberg/freightdb/src/main.zig -fno-strip -ODebug -Mziggy=/home/cyrilguiz/.cache/zig/p/1220037474a924385b0d2ccb0e5c416c595f43f93a3450d55f8b6d5ad6f3ba091ca5/src/root.zig --cache-dir /home/cyrilguiz/.codeberg/freightdb/zig-cache --global-cache-dir /home/cyrilguiz/.cache/zig --name freightdb --listen=-
Build Summary: 0/5 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run freightdb transitive failure
   ├─ zig build-exe freightdb Debug native failure
   └─ install transitive failure
      └─ install freightdb transitive failure
         └─ zig build-exe freightdb Debug native (reused)
error: the following build command failed with exit code 1:
/home/cyrilguiz/.codeberg/freightdb/zig-cache/o/910c81e0e7016424591fda243bd2ce98/build /nix/store/n146fdz4qp6flryj8bw8bqly0q8mg18j-zig-0.12.0-dev.3434+e90583f5d/bin/zig /home/cyrilguiz/.codeberg/freightdb /home/cyrilguiz/.codeberg/freightdb/zig-cache /home/cyrilguiz/.cache/zig --seed 0x15f25e4e -Z97e6a20565b9ceee run

I don’t know why this happens.
This is the build.zig file:

const std: type = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const exe = b.addExecutable(.{
        .name = "freightdb",
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,

    const ziggy = b.dependency("ziggy", .{
        .target = target,
        .optimize = optimize,
    exe.root_module.addImport("ziggy", ziggy);

    const run_cmd = b.addRunArtifact(exe);
    if (b.args) |args| {
    const run_step = b.step("run", "Run the app");

    const unit_tests = b.addTest(.{
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    const run_unit_tests = b.addRunArtifact(unit_tests);
    const test_step = b.step("test", "Run unit tests");

There are other files in my project to see them visit codeberg

If you’re running on a nightly build on Zig, this is probably related to a recent regression – I know the issue title makes it seem different, but that bug is quite significant and can manifest in several ways. A fix for the bug has hit master, and that commit will be in the next tarball build, but that won’t be online for a good few hours yet.

As a workaround in the meantime, deleting the zig-cache/ and ~/.cache/zig/ directories when you encounter the crash (an uninformative “segfault”, or “the following command terminated unexpectedly”) should work. Apologies for the instability here!


I am using zig-overlay on nixos, do does this apply to my case as well?