jdx/mise · error

watch_files command failed: {status}

Error message

watch_files command failed: {status}

What it means

watch_files::execute runs the file-watcher command and bails when the child process exits with a non-success status. On Windows it runs the command with a scrubbed environment capturing stdout to stderr; any nonzero exit of the watch command produces this error with the platform's ExitStatus rendering.

Source

Thrown at src/watch_files.rs:128

        "MISE_PROJECT_ROOT".to_string(),
        root.to_string_lossy().to_string(),
    );
    // TODO: this should be different but I don't have easy access to it
    // env.insert("MISE_CONFIG_ROOT".to_string(), root.to_string_lossy().to_string());
    // On Windows, `cmd /c <run>` must receive the command verbatim so inner
    // double quotes survive (#9355). Mirror the hook path: spawn a raw Command
    // with stdout redirected to our stderr handle (duct's stdout_to_stderr) and
    // the full env. Non-cmd shells / Unix fall through to the duct path below.
    #[cfg(windows)]
    {
        if let Some(mut c) = crate::path::cmd_verbatim_command(program, shell_args, run) {
            use std::os::windows::io::AsHandle;
            c.env_clear();
            c.envs(env.iter());
            c.stdout(std::io::stderr().as_handle().try_clone_to_owned()?);
            let status = c.status()?;
            if !status.success() {
                eyre::bail!("watch_files command failed: {status}");
            }
            return Ok(());
        }
    }
    crate::inline_command::optimize_expression(
        cmd(program, args).full_env(&env),
        run,
        &env,
        None,
        direct_enabled,
    )
    .stdout_to_stderr()
    .run()?;
    Ok(())
}

async fn execute_task(
    config: &Arc<Config>,

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Fix the underlying command that failed — run it directly (outside watch mode) and address its own error output.
  2. Verify the watcher binary/dependency exists and runs on this platform, especially on Windows where the code path differs.
  3. Check that the task doesn't depend on environment variables removed by the Windows env_clear branch; set them via mise [env] config.
  4. Re-run mise watch after fixing; if it persists, capture stderr (which the command's stdout is redirected to) for the watcher's own message.

Example fix

// before (task failing under watch)
[task.dev]
run = "node build.js"
// after — fix the failing build command first
[task.dev]
run = "node build.js"
# then: mise watch task dev
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the watch command exits 0 before enabling watch mode:
const probe = run(cmd, args); if (probe.status !== 0) throw new Error(`watch cmd fails standalone: ${probe.stderr}`);

Try / catch

try {
  run('mise watch', ['task', 'dev']);
} catch (e) {
  if (/watch_files command failed/.test(String(e))) {
    console.error('watched command failed; run it directly to see the real error');
    run(cmd, args); // surface the underlying failure
  } else throw e;
}

Prevention

When it happens

Trigger: The command mise watches files with (e.g. a task's watch command or a watcher binary) exits nonzero — the watcher crashed, the watched command failed, or the env required by the watcher was cleared.

Common situations: A watch task wrapping a build that fails on change (syntax error), the watcher binary missing required environment variables after env_clear, or Ctrl-C/abnormal termination of the watcher being treated as a failed status.

Related errors


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