jdx/mise · error

watch file no longer exists: {}

Error message

watch file no longer exists: {}

What it means

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.

Source

Thrown at src/toolset/env_cache.rs:69

        .map_err(|e| eyre::eyre!("failed to create cipher: {}", e))?;

    let plaintext = cipher
        .decrypt(&nonce, ciphertext)
        .map_err(|e| eyre::eyre!("decryption failed: {}", e))?;
    Ok(plaintext)
}

fn validate_watch_files(watch_files: &[PathBuf], expected_mtimes: &[u64]) -> Result<()> {
    if watch_files.len() != expected_mtimes.len() {
        bail!("watch file count mismatch");
    }
    for (path, expected_mtime) in watch_files.iter().zip(expected_mtimes.iter()) {
        if !path.exists() {
            // mtime=0 means file didn't exist when cached - skip if still doesn't exist
            if *expected_mtime == 0 {
                continue;
            }
            bail!("watch file no longer exists: {}", path.display());
        }
        if let Some(current_mtime) = get_file_mtime(path) {
            if current_mtime != *expected_mtime {
                bail!(
                    "watch file mtime changed: {} (expected: {}, current: {})",
                    path.display(),
                    expected_mtime,
                    current_mtime
                );
            }
        } else {
            bail!("could not get mtime for watch file: {}", path.display());
        }
    }
    Ok(())
}

/// Represents the cached environment data

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Let mise regenerate the cache (it is automatic after this bail) and re-run the command
  2. Recreate the deleted/moved watch file if it was intentional to keep it
  3. Re-run `mise install` or regenerate any file your config expects to exist
  4. Remove the stale cache entry with `mise cache clear`

Example fix

// before: .env deleted, cache still references it
rm .env && mise run dev  # watch file no longer exists: /proj/.env
// after: recreate or update config to drop the file dependency
mise run dev   # cache rebuilt without missing file
Defensive patterns

Strategy: validation

Validate before calling

// verify watched files exist before expecting cache hits
for (const f of watchFiles) { if (!fs.existsSync(f)) regenerateOrRecreate(f); }

Type guard

const watchedFilesExist = (files) => files.every(f => fs.existsSync(f));

Try / catch

try { loadEnvCache() } catch (e) { if (String(e).includes('watch file no longer exists')) { recreateMissingFile(); loadEnvCache(); } else { throw e; } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/50876de85751e675. Report an issue: GitHub.