Follow-up from #20580.
name_to_handle_at gives us a mount ID here:
| tryposix.name_to_handle_at(path.root_dir.handle.fd, adjusted_path, stack_ptr, &mount_id, std.os.linux.AT.HANDLE_FID); |
A given fanotify file descriptor (created by fanotify_init) can only contain marks from the same mount ID. So if we get a different mount ID here, we need to put it into a new fanotify set. The poll later on needs to poll all of them.
Without this fix, we get errors such as
error: unable to watch /nix/store/0c5jp9d9h9818arr6s21xibgjl1ybql0-glibc-2.39-52-dev/include: NotSameFileSystem
Some commonly used Linux distributions will put the Zig standard library into a different mount than the user's home directory, resulting in this problem.
Workaround:
--- a/lib/std/Build/Watch.zig+++ b/lib/std/Build/Watch.zig@@ -175,7 +175,7 @@ const Os = switch (builtin.os.tag) {
.ADD = true,
.ONLYDIR = true,
}, fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| {
- fatal("unable to watch {}: {s}", .{ path, @errorName(err) });+ std.log.warn("unable to watch {}: {s}", .{ path, @errorName(err) });
};
}
break :rs dh_gop.value_ptr;You can apply this workaround without recompiling Zig.
Related:
Follow-up from #20580.
name_to_handle_atgives us a mount ID here:zig/lib/std/Build/Watch.zig
Line 101 in 8ab70f8
A given fanotify file descriptor (created by
fanotify_init) can only contain marks from the same mount ID. So if we get a different mount ID here, we need to put it into a new fanotify set. The poll later on needs to poll all of them.Without this fix, we get errors such as
Some commonly used Linux distributions will put the Zig standard library into a different mount than the user's home directory, resulting in this problem.
Workaround:
You can apply this workaround without recompiling Zig.
Related: