jdx/mise · error
exec command failed
Error message
exec command failed: {} What it means
The Tera v1 `exec` template function runs a shell command during template rendering and requires a zero exit status. On non-zero exit, mise bails with the command's stderr as the message, so template rendering aborts. This surfaces underlying command failures (missing tools, test failures, script errors) at template-evaluation time.
Solutions
- Run the command from the error's stderr manually and fix the underlying failure.
- Ensure the command exists on PATH inside mise (use mise shims or full path).
- Make the command tolerant: append `|| true` or `2>/dev/null || echo fallback`.
- If output goes to stderr, redirect it (cmd 2>&1) so success path works too.
Example fix
# before
[env]
FOO = "{{ exec(command='possibly-missing-tool --flag') }}"
# after
[env]
FOO = "{{ exec(command='possibly-missing-tool --flag 2>/dev/null || echo default') }}" Defensive patterns
Strategy: try-catch
Try / catch
// tolerate failing exec commands in templates
[env]
FOO = "{{ exec(command='cmd --flag 2>/dev/null || echo fallback') }}" Prevention
- Only call exec() on commands guaranteed present in mise's environment.
- Append `|| echo <default>` fallbacks to optional commands.
- Test templates with `mise env` before relying on them.
When it happens
Trigger: A template invokes exec(command=...) via parse_template/get_tera_v1 and the spawned command exits non-zero (e.g. `exec(command="foo --version")` where foo is missing or fails).
Common situations: mise.toml env/template values calling exec on tools not yet installed; PATH differences between shell and mise context; commands that fail intermittently (network checks); typos in the executed command.
Related errors
- an exec entry with no command
- bootstrap_command returned an unsafe mise path
- bootstrap plan contains resources with unknown state
- brew-cask: failed to generate
- Check shell must not be empty
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/a595903a8a319817.
Report an issue: GitHub.
Appendix: source
Thrown at src/tera.rs:1525
.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 533346cc37)