jdx/mise · error
exec command failed: {}
Error message
exec command failed: {} What it means
The Tera v1 template `exec` function runs a shell command as a subprocess and requires it to exit successfully; on a non-zero status mise bails with the command's stderr as the message. Template rendering thus fails whenever an embedded exec command fails.
Source
Thrown at src/tera.rs:1466
.collect::<Vec<String>>();
let mut env_no_shims = env.clone();
if let Some(path_val) = env_no_shims.get(&*env::PATH_KEY).cloned() {
env_no_shims.insert(env::PATH_KEY.to_string(), strip_shims_from_path(&path_val));
}
let run_once = || -> eyre::Result<String> {
#[cfg(windows)]
{
if let Some(mut c) =
crate::path::cmd_verbatim_command(&shell[0], &shell[1..], command)
{
c.env_clear();
c.envs(env_no_shims.iter());
if let Some(dir) = &dir {
c.current_dir(dir);
}
let out = c.output()?;
if !out.status.success() {
eyre::bail!(
"exec command failed: {}",
String::from_utf8_lossy(&out.stderr)
);
}
let mut s = String::from_utf8(out.stdout)?;
while s.ends_with('\n') || s.ends_with('\r') {
s.pop();
}
return Ok(s);
}
}
let mut expr: duct::Expression = cmd(&shell[0], &shell_args).full_env(&env_no_shims);
if let Some(dir) = &dir {
expr = expr.dir(dir);
}
Ok(crate::inline_command::optimize_expression(
expr,
command,View on GitHub (pinned to afd2eddd3a)
Solutions
- Run the failing command manually and fix why it exits non-zero (the stderr in the error shows the cause)
- Ensure the command is installed/on PATH for the mise environment (shims are stripped from exec env)
- Check the `dir` argument of the exec call points to the intended working directory
Example fix
// before (template)
{{ exec(command="git rev-parse --verify HEAD^9") }}
// after
{{ exec(command="git rev-parse --verify HEAD~9 || echo unknown") }} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check a command before embedding it in a template
const { status } = Bun.spawnSync(['git', 'rev-parse', 'HEAD']);
if (status !== 0) throw new Error('git not usable in mise exec environment'); Try / catch
// wrap template rendering that uses exec()
match render() {
Err(e) if e.to_string().contains("exec command failed") => {
eprintln!("template exec failed: {e:#}; check PATH/dir of embedded command");
}
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Remember exec strips mise shims from the environment — only real PATH tools run
- Test template commands in a bare shell first
- Give exec an explicit dir argument when the command depends on cwd
- Make embedded commands defensive (|| echo fallback) when failure is tolerable
When it happens
Trigger: A mise.toml template uses `{{ exec(command="...") }}` (or parse_template/get_tera_v1 evaluates a template containing it) and the command exits non-zero — e.g. missing binary, failing script, or wrong cwd/dir argument.
Common situations: Referencing a command not installed in the environment the task runs in; a script that depends on files in the wrong working directory; environment differences (env_no_shims) hiding tools normally available via shims.
Related errors
- {} failed
- ditto failed copying {} to {}
- brew-cask: failed to generate {} completions from {}: {}
- unexpected character: {}
- expected closing parenthesis
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/a595903a8a319817.
Report an issue: GitHub.