{"record":{"id":"50876de85751e675","repo":"jdx/mise","slug":"watch-file-no-longer-exists","errorCode":null,"errorMessage":"watch file no longer exists: {}","messagePattern":"watch file no longer exists: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/toolset/env_cache.rs","lineNumber":69,"sourceCode":"        .map_err(|e| eyre::eyre!(\"failed to create cipher: {}\", e))?;\n\n    let plaintext = cipher\n        .decrypt(&nonce, ciphertext)\n        .map_err(|e| eyre::eyre!(\"decryption failed: {}\", e))?;\n    Ok(plaintext)\n}\n\nfn validate_watch_files(watch_files: &[PathBuf], expected_mtimes: &[u64]) -> Result<()> {\n    if watch_files.len() != expected_mtimes.len() {\n        bail!(\"watch file count mismatch\");\n    }\n    for (path, expected_mtime) in watch_files.iter().zip(expected_mtimes.iter()) {\n        if !path.exists() {\n            // mtime=0 means file didn't exist when cached - skip if still doesn't exist\n            if *expected_mtime == 0 {\n                continue;\n            }\n            bail!(\"watch file no longer exists: {}\", path.display());\n        }\n        if let Some(current_mtime) = get_file_mtime(path) {\n            if current_mtime != *expected_mtime {\n                bail!(\n                    \"watch file mtime changed: {} (expected: {}, current: {})\",\n                    path.display(),\n                    expected_mtime,\n                    current_mtime\n                );\n            }\n        } else {\n            bail!(\"could not get mtime for watch file: {}\", path.display());\n        }\n    }\n    Ok(())\n}\n\n/// Represents the cached environment data","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/toolset/env_cache.rs#L51-L87","documentation":"During env-cache validation, a watched file listed in the cache (that had a nonzero mtime when cached) no longer exists on disk. Since the environment derived from that file may no longer be valid, `load` bails and the cache is treated as stale.","triggerScenarios":"Calling `load` where a watch file with a nonzero expected_mtime is missing: the file was deleted/moved between caching and now, and expected_mtime != 0.","commonSituations":"A dotenv/config file watched by the cache was deleted, a git checkout removed a file, or a project directory was cleaned.","solutions":["Restore the missing file (e.g. `git checkout -- <file>`) or accept the invalidation.","Clear the env cache and re-run so it rebuilds against current files.","If the file is intentionally gone, re-run the mise command — a fresh cache entry will exclude it.","Check whether a branch switch or tool run deleted the file."],"exampleFix":"// before\ngit status  # .env missing\n// after\ngit checkout -- .env  # or delete stale cache and re-run","handlingStrategy":"fallback","validationCode":"if watch_files.iter().any(|p| !p.exists()) { /* rebuild cache */ }","typeGuard":null,"tryCatchPattern":"match env_cache::load(...) { Err(e) if e.to_string().contains(\"no longer exists\") => recompute_env(), other => other? }","preventionTips":["Avoid deleting files that are part of the tracked env while a shell session is active.","Restore tracked dotfiles with git before relying on cached env.","Keep cache invalidation as a normal code path, not an error."],"tags":["cache","file-missing","invalidation"],"backgroundTag":"file-not-found","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}