Panic: nothing to watch. zig build run -fincremental --watch

Before I file an issue, I wanted some thoughts.

When using zig version 0.17.0-dev.298+ad1b746e2, I get the below error where the first build runs successfully, but then any save after that triggers the panic. If I make any changes or not, the panic is triggered anyways.

This error does not exist in zig 0.16.0.

Hello world
info: Creating new user
Build Summary: 5/5 steps succeeded
Hello world
info: Creating new user
Build Summary: 5/5 steps succeeded
thread 794957 panic: nothing to watch
/Users/nathaniel/.zvm/master/lib/std/Build/Watch/FsEvents.zig:210:35: 0x10486ed7b in wait (build)
    if (fse.watch_roots.len == 0) @panic("nothing to watch");
                                  ^
/Users/nathaniel/.zvm/master/lib/std/Build/Watch.zig:865:33: 0x1048666a3 in wait (build)
            return w.os.fse.wait(gpa, switch (timeout) {
                                ^
/Users/nathaniel/.zvm/master/lib/std/Build/Watch.zig:967:19: 0x10486679b in wait (build)
    return Os.wait(w, gpa, io, timeout);
                  ^
/Users/nathaniel/.zvm/master/lib/compiler/build_runner.zig:623:40: 0x10486d18b in main (build)
        while (true) switch (try w.wait(gpa, io, if (in_debounce) .{ .ms = debounce_interval_ms } else .none)) {
                                       ^
/Users/nathaniel/.zvm/master/lib/std/start.zig:712:88: 0x10486d9bf in callMain (build)
    if (fn_info.params[0].type.? == std.process.Init.Minimal) return wrapMain(root.main(.{
                                                                                       ^
???:?:?: 0x186875d53 in start (/usr/lib/dyld)
error: the following build command terminated with signal ABRT:

What is your build.zig file (and maybe also the rest of your source code)? That would provide some valuable information.

I have a vanilla zig init project with a simple hello world. Changing the zig version is what’s causing the issue.

I think the core team is actively working on -fincremental right now, e.g. https://codeberg.org/ziglang/zig/issues/30780 . I tried to repro and got different results: it works fine but it doesn’t reflect my changes at all (I changed the “all your codebase” string in between the two runs, but it didn’t pick it up)

$ zig version
0.17.0-dev.313+27be3b069
$ zig env | grep target
    .target = "x86_64-linux.6.12.68...6.12.68-gnu.2.42",
$ zig init
info: created build.zig
...
 $ zig build run --watch -fincremental
All your codebase are belong to us.
info: arg: /tmp/tmp.siaRWo2E1N/zig-out/bin/tmp_siaRWo2E1N
Run `zig build test` to run the tests.
Build Summary: 5/5 steps succeeded
All your codebase are belong to us.
info: arg: /tmp/tmp.siaRWo2E1N/zig-out/bin/tmp_siaRWo2E1N
Run `zig build test` to run the tests.
Build Summary: 5/5 steps succeeded
watching 77 directories, 1 processes

fwiw if you remove -fincremental (but keep --watch) it works as expected, in this case and in the issue I linked.

(edit: I posted my specific issue here: https://codeberg.org/ziglang/zig/issues/35365 - it has to do with /tmp and -fincremental it seems)

1 Like