{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","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/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/toolset/env_cache.rs#L51-L87","documentation":"During cache validation mise found a watched file that existed when the env was cached but is now gone, and its cached mtime was non-zero (so its absence isn't tolerated). Since the file's change can invalidate the cached env, mise bails instead of reusing stale data.","triggerScenarios":"env_cache::load validates watch files and path.exists() returns false while expected_mtime != 0 — i.e. a file listed in the cache (a config file, env file, tool version file) was deleted or moved since the cache was written.","commonSituations":"Deleting or renaming a .env, mise.toml, or .tool-versions file that the cached env depended on; a git checkout/clean removing a generated env file; moving a project directory.","solutions":["Let mise regenerate the cache (it is automatic after this bail) and re-run the command","Recreate the deleted/moved watch file if it was intentional to keep it","Re-run `mise install` or regenerate any file your config expects to exist","Remove the stale cache entry with `mise cache clear`"],"exampleFix":"// before: .env deleted, cache still references it\nrm .env && mise run dev  # watch file no longer exists: /proj/.env\n// after: recreate or update config to drop the file dependency\nmise run dev   # cache rebuilt without missing file","handlingStrategy":"validation","validationCode":"// verify watched files exist before expecting cache hits\nfor (const f of watchFiles) { if (!fs.existsSync(f)) regenerateOrRecreate(f); }","typeGuard":"const watchedFilesExist = (files) => files.every(f => fs.existsSync(f));","tryCatchPattern":"try { loadEnvCache() } catch (e) { if (String(e).includes('watch file no longer exists')) { recreateMissingFile(); loadEnvCache(); } else { throw e; } }","preventionTips":["Don't delete config/env files your mise setup watches without clearing cache","Use git checkout patterns that preserve expected env files","Regenerate required files before running mise commands","Keep .env and config files in stable locations"],"tags":["cache","file-not-found","env"],"backgroundTag":"file-not-found","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}