A cross-platform file system monitor for Unison that enables the -repeat watch option.
Unison doesn't include unison-fsmonitor for macOS, thus the -repeat watch option doesn't work out of the box. This utility fills the gap. While originally made for macOS, it works on other platforms as well.
Stable and Production Ready - This project has been used in production for many years by the author and colleagues to sync codebases between macOS and Linux. It is actively maintained with regular releases.
This project uses the notify crate for cross-platform file system monitoring:
| Platform | Status | Kernel Interface |
|---|---|---|
| macOS (Intel & Apple Silicon) | ✅ Tested | FSEvents |
| Linux | ✅ Tested | inotify |
| Windows | ✅ Tested | ReadDirectoryChangesW |
| BSDs (FreeBSD, NetBSD, OpenBSD) | kqueue | |
| illumos/Solaris | - |
*BSDs and illumos are theoretically supported via the notify crate but have not been tested by the maintainer. Contributions for testing on these platforms are welcome!
For a complete list of platforms supported by the notify crate, see: https://github.com/notify-rs/notify#platforms
- No additional requirements beyond what Homebrew or Cargo provides.
- Rust compiler (stable toolchain) - Install via rustup
- Platform-specific requirements:
- macOS: Xcode Command Line Tools (
xcode-select --install) - Linux: Standard build tools (gcc, make, etc.) - usually pre-installed
- Windows: Microsoft Visual C++ Build Tools or equivalent
- macOS: Xcode Command Line Tools (
brew install autozimu/homebrew-formulas/unison-fsmonitorIf you have Rust and Cargo installed:
cargo install unison-fsmonitorgit clone https://github.com/autozimu/unison-fsmonitor.git
cd unison-fsmonitor
cargo build --release
# Binary will be at target/release/unison-fsmonitor. Link/Add to your PATH.Simply run unison with -repeat watch as argument or repeat=watch in your config file:
unison -repeat watch /path/to/replica1 /path/to/replica2Or in your Unison profile (~/.unison/*.prf):
repeat = watch
You might need to update file watch limits on both hosts if the watching limit is reached. See the Watchman documentation for system-specific instructions.
To enable debug logging:
RUST_LOG=debug unison- Unison fsmonitor protocol: https://github.com/bcpierce00/unison/blob/af8669bb26f88e85bdc37cb1ff23d9bb0685a1e2/src/fswatch.ml
- Unison watcher common: https://github.com/bcpierce00/unison/blob/master/src/fsmonitor/watchercommon.ml
- Unox (another fsmonitor implementation): https://github.com/hnsl/unox
- Notify crate (underlying file watching library): https://github.com/notify-rs/notify