{"record":{"id":"6c4a8724390c04a1","repo":"jdx/mise","slug":"watch-files-command-failed-status","errorCode":null,"errorMessage":"watch_files command failed: {status}","messagePattern":"watch_files command failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/watch_files.rs","lineNumber":128,"sourceCode":"        \"MISE_PROJECT_ROOT\".to_string(),\n        root.to_string_lossy().to_string(),\n    );\n    // TODO: this should be different but I don't have easy access to it\n    // env.insert(\"MISE_CONFIG_ROOT\".to_string(), root.to_string_lossy().to_string());\n    // On Windows, `cmd /c <run>` must receive the command verbatim so inner\n    // double quotes survive (#9355). Mirror the hook path: spawn a raw Command\n    // with stdout redirected to our stderr handle (duct's stdout_to_stderr) and\n    // the full env. Non-cmd shells / Unix fall through to the duct path below.\n    #[cfg(windows)]\n    {\n        if let Some(mut c) = crate::path::cmd_verbatim_command(program, shell_args, run) {\n            use std::os::windows::io::AsHandle;\n            c.env_clear();\n            c.envs(env.iter());\n            c.stdout(std::io::stderr().as_handle().try_clone_to_owned()?);\n            let status = c.status()?;\n            if !status.success() {\n                eyre::bail!(\"watch_files command failed: {status}\");\n            }\n            return Ok(());\n        }\n    }\n    crate::inline_command::optimize_expression(\n        cmd(program, args).full_env(&env),\n        run,\n        &env,\n        None,\n        direct_enabled,\n    )\n    .stdout_to_stderr()\n    .run()?;\n    Ok(())\n}\n\nasync fn execute_task(\n    config: &Arc<Config>,","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/watch_files.rs#L110-L146","documentation":"This error is thrown in the watch_files command executor when a spawned subprocess (the file-watching command) exits with a non-zero status. The command is run with a cleared environment plus explicitly passed env vars and stdout redirected to stderr. It signals that the watcher process itself failed, not that mise failed to spawn it.","triggerScenarios":"The child process spawned in `execute` returns a failing exit status from `c.status()`; any invocation of the watch_files inline command whose underlying watcher binary or script exits non-zero.","commonSituations":"The watch command crashes on invalid arguments, the watched tool binary is missing or misconfigured, environment variables passed to the watcher are wrong, or the watcher is killed and reports a non-zero code.","solutions":["Run the watch command manually with the same arguments to see its actual error output (stdout/stderr is forwarded to stderr)","Fix the arguments or configuration of the underlying watch command so it exits 0","Check that the env vars being forwarded are correct and that env_clear is not dropping vars the watcher needs","Verify the target tool/binary the watcher invokes is installed and on PATH"],"exampleFix":"// before\nmise watch --bad-flag src\n// after\nmise watch --correct-flag src","handlingStrategy":"try-catch","validationCode":"// verify the watch command exits cleanly before relying on it\nmise watch --dry-run src || echo \"watch command itself fails\"","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"watch_files command failed\") => {\n        eprintln!(\"watcher exited non-zero; rerun the command manually to see its error\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Smoke-test the watch command manually after changing its arguments","Keep forwarded env vars minimal and documented","Ensure the watched tool is installed and on PATH","Check exit codes of the watcher in CI"],"tags":["subprocess","watch-files","windows","process-exit"],"backgroundTag":"git-command-failed","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"}