jdx/mise · error

cannot watch : the system's watch limit is reached (on…

Error message

cannot watch {}: the system's watch limit is reached (on Linux raise fs.inotify.max_user_watches)

What it means

The watch runtime installs a notify/debouncer watch for each anchor path. When the OS reports MaxFilesWatch and no watches are installed yet, it aborts: without a watch, changes would never be detected. On Linux this means the inotify per-user watch limit is exhausted.

Solutions

  1. Raise the Linux inotify limit: `sudo sysctl fs.inotify.max_user_watches=524288` (persist in /etc/sysctl.conf or /etc/sysctl.d/).
  2. Reduce the watched footprint: untrack or exclude very large directories.
  3. On macOS/Windows, close apps consuming FSEvents/ReadDirectoryChangesW resources or reboot to clear leaked watches.

Example fix

// before (default 8192 watches)
// after
sudo sysctl -w fs.inotify.max_user_watches=524288
echo 'fs.inotify.max_user_watches=524288' | sudo tee /etc/sysctl.d/99-inotify.conf && sudo sysctl --system
Defensive patterns

Strategy: fallback

Validate before calling

// Linux: check available inotify watches
let max = std::fs::read_to_string("/proc/sys/fs/inotify/max_user_watches").ok().and_then(|s| s.trim().parse::<u64>().ok());
if max.is_some_and(|m| m < 524288) { eprintln!("consider raising fs.inotify.max_user_watches"); }

Try / catch

match install_watches() {
  Err(e) if e.to_string().contains("watch limit") => { raise_inotify_or_poll_fallback(); }
  other => other?,
}

Prevention

When it happens

Trigger: install (called by run/reinstall) calls debouncer.watch(anchor) which returns notify::ErrorKind::MaxFilesWatch while `current` is empty, i.e. the very first anchor cannot be watched.

Common situations: Large tracked sets, many other apps consuming inotify watches, containers with low fs.inotify.max_user_watches defaults, syncing huge directories like node_modules under a watched root.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/552d3d8d590c7f10. Report an issue: GitHub.

Appendix: source

Thrown at src/system/history/watch/runtime.rs:1408

        if wanted.contains(anchor) {
            current.push(anchor.clone());
        } else if let Err(err) = debouncer.unwatch(&anchor.path) {
            debug!("history watch: unwatch {}: {err}", anchor.path.display());
        }
    }
    for anchor in wanted {
        if current.contains(anchor) {
            continue;
        }
        let mode = match anchor.mode {
            Mode::Recursive => RecursiveMode::Recursive,
            Mode::Flat => RecursiveMode::NonRecursive,
        };
        match debouncer.watch(&anchor.path, mode) {
            Ok(()) => current.push(anchor.clone()),
            Err(err) if matches!(err.kind, notify::ErrorKind::MaxFilesWatch) => {
                if current.is_empty() {
                    bail!(
                        "cannot watch {}: the system's watch limit is reached (on Linux raise fs.inotify.max_user_watches)",
                        display_path(&anchor.path)
                    );
                }
                let message = format!(
                    "cannot watch {}: the system's watch limit is reached; reconciliation still saves it (on Linux raise fs.inotify.max_user_watches)",
                    display_path(&anchor.path)
                );
                capture.health.watcher.degraded.push(message.clone());
                capture.out.emit(
                    "degraded",
                    &message,
                    json!({ "path": display_path(&anchor.path) }),
                );
            }
            Err(err) => {
                let message = format!(
                    "cannot watch {}: {err}; reconciliation still saves it",

View on GitHub (pinned to 533346cc37)