nikivdev/code · error

watch path {} does not exist (watcher {})

Error message

watch path {} does not exist (watcher {})

What it means

run_shell_watcher starts a shell-based file watcher for the configured path. Before spawning, it expands the path (e.g. ~ expansion) and checks existence; if the path does not exist it bails with an error naming both the resolved path and the watcher's configured name, so the user can identify which watcher entry in their config is broken.

Source

Thrown at src/watchers.rs:105

        })
    }
}

impl Drop for WatcherHandle {
    fn drop(&mut self) {
        if let Some(tx) = self.shutdown.take() {
            let _ = tx.send(());
        }
        if let Some(handle) = self.join.take() {
            let _ = handle.join();
        }
    }
}

fn run_shell_watcher(cfg: WatcherConfig, shutdown: Receiver<()>) -> Result<()> {
    let watch_path = expand_path(&cfg.path);
    if !watch_path.exists() {
        anyhow::bail!(
            "watch path {} does not exist (watcher {})",
            watch_path.display(),
            cfg.name
        );
    }

    let workdir = if watch_path.is_dir() {
        watch_path.clone()
    } else {
        watch_path
            .parent()
            .map(Path::to_path_buf)
            .unwrap_or_else(|| PathBuf::from("."))
    };

    if cfg.run_on_start {
        run_command(&cfg, &workdir);
    }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Check the path printed in the error; create the directory (`mkdir -p <path>`) or correct the `path` in the watcher config.
  2. Use an absolute path in the config to avoid working-directory surprises.
  3. If using `~` or variables, verify what expand_path produces (run the same expansion manually) and adjust the config accordingly.
  4. In containers/services, ensure the path is mounted/exists in that environment, not just on the host.

Example fix

// before (config)
[[watcher]]
name = "assets"
path = "~/projets/assets"   # typo: directory does not exist
// after
[[watcher]]
name = "assets"
path = "/home/me/projects/assets"
Defensive patterns

Strategy: validation

Validate before calling

use std::path::PathBuf;
fn validate_watcher_path(raw: &str, name: &str) -> Result<PathBuf, String> {
    let p = shellexpand::tilde(raw);
    let path = PathBuf::from(p.as_ref());
    if !path.exists() {
        return Err(format!("watcher '{name}': path {} does not exist", path.display()));
    }
    Ok(path)
}

Prevention

When it happens

Trigger: Calling spawn_shell with a WatcherConfig whose `path`, after expand_path() resolves it, does not exist on disk — typo'd directory, nonexistent relative path, or unexpanded/incorrect home-relative path.

Common situations: Typo in the watcher config's path field; using a path with `~` or env vars that expand_path does not resolve as expected; directory deleted/renamed after config was written; running in a container where the host path was not mounted; relative path interpreted against a different working directory than assumed.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/1a090ddb393c9552. Report an issue: GitHub.