#Can't use std.fs.watch on M1 Mac

1 messages · Page 1 of 1 (latest)

loud merlin
#

I tried to use the test case in the watch.zig file from the std source as an example to listen to changes to a text file. But I'm getting an error I can't figure out when initializing the watcher:

watch.zig:146:59: error: container 'std.hash_map.HashMapUnmanaged([]const u8,*std.fs.watch.Put,std.hash_map.StringContext,80)' has no member called 'init'
  .file_table = OsData.FileTable.init(allocator),

watch.zig:283:33: error: container 'std.os' has no member called 'EVFILT_VNODE'

The only difference between the test case I used as an example and my code is that I'm using a std.heap.page_allocator which is what I pass to the Watch init var watch = try std.fs.Watch(void).init(allocator, 0);. Maybe that's related to the issue?

Can anyone help me on how to solve or debug this? Thanks!

#

Can't use std.fs.watch on M1 Mac

fading jacinth
#

std.fs.Watch is likely bitrotted, it's not used internally for anything and it has no tests at all

loud merlin
#

I guess that explains it haha is there any sources I can look at to manually implement a file watcher?

ebon canyon
#

You could start with the code in std/fs/watch.zig and fix it as needed. File watching is OS-specific, so you could pull out just the parts for the OS you need.

If it goes well you could consider contributing fixes to the Zig code.

fast sandal