{"record":{"id":"1a090ddb393c9552","repo":"nikivdev/code","slug":"watch-path-does-not-exist-watcher","errorCode":null,"errorMessage":"watch path {} does not exist (watcher {})","messagePattern":"watch path (.+?) does not exist \\(watcher (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/watchers.rs","lineNumber":105,"sourceCode":"        })\n    }\n}\n\nimpl Drop for WatcherHandle {\n    fn drop(&mut self) {\n        if let Some(tx) = self.shutdown.take() {\n            let _ = tx.send(());\n        }\n        if let Some(handle) = self.join.take() {\n            let _ = handle.join();\n        }\n    }\n}\n\nfn run_shell_watcher(cfg: WatcherConfig, shutdown: Receiver<()>) -> Result<()> {\n    let watch_path = expand_path(&cfg.path);\n    if !watch_path.exists() {\n        anyhow::bail!(\n            \"watch path {} does not exist (watcher {})\",\n            watch_path.display(),\n            cfg.name\n        );\n    }\n\n    let workdir = if watch_path.is_dir() {\n        watch_path.clone()\n    } else {\n        watch_path\n            .parent()\n            .map(Path::to_path_buf)\n            .unwrap_or_else(|| PathBuf::from(\".\"))\n    };\n\n    if cfg.run_on_start {\n        run_command(&cfg, &workdir);\n    }","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/watchers.rs#L87-L123","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the path printed in the error; create the directory (`mkdir -p <path>`) or correct the `path` in the watcher config.","Use an absolute path in the config to avoid working-directory surprises.","If using `~` or variables, verify what expand_path produces (run the same expansion manually) and adjust the config accordingly.","In containers/services, ensure the path is mounted/exists in that environment, not just on the host."],"exampleFix":"// before (config)\n[[watcher]]\nname = \"assets\"\npath = \"~/projets/assets\"   # typo: directory does not exist\n// after\n[[watcher]]\nname = \"assets\"\npath = \"/home/me/projects/assets\"","handlingStrategy":"validation","validationCode":"use std::path::PathBuf;\nfn validate_watcher_path(raw: &str, name: &str) -> Result<PathBuf, String> {\n    let p = shellexpand::tilde(raw);\n    let path = PathBuf::from(p.as_ref());\n    if !path.exists() {\n        return Err(format!(\"watcher '{name}': path {} does not exist\", path.display()));\n    }\n    Ok(path)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths in watcher configs instead of `~` or env-var-relative ones","Validate all configured watch paths at startup before spawning any watchers","Re-validate after directory renames/deletions or when configs are edited","In containers/services, confirm the path is mounted and exists in the runtime environment"],"tags":["filesystem","watcher","config","path-not-found"],"backgroundTag":"watch-path-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}