jdx/mise · error
Environment variable {key} not found
Error message
Environment variable {key} not found What it means
`mise set KEY` with a single bare key (no =VALUE, no --prompt, no --stdin) is the read form of the command: mise resolves the merged config environment through Config::env() — which includes decrypting age-encrypted entries — and prints the value. If the key is not defined in any mise config's [env], it bails 'Environment variable {key} not found'. It reads mise config env, not the process environment.
Source
Thrown at src/cli/set.rs:155
mise_toml.remove_env(name)?;
}
}
if let Some(env_vars) = &self.env_vars
&& env_vars.len() == 1
&& env_vars[0].value.is_none()
&& !self.prompt
&& !self.stdin
{
let key = &env_vars[0].key;
// Use Config's centralized env loading which handles decryption
let full_config = Config::get().await?;
let env = full_config.env().await?;
match env.get(key) {
Some(value) => {
miseprintln!("{value}");
}
None => bail!("Environment variable {key} not found"),
}
return Ok(());
}
if let Some(mut env_vars) = self.env_vars.take() {
// Prompt for values if requested
if self.prompt {
let theme = crate::ui::theme::get_theme();
for ev in &mut env_vars {
if ev.value.is_none() {
let prompt_msg = format!("Enter value for {}", ev.key);
let value = Input::new(&prompt_msg)
.password(self.age_encrypt) // Mask input if encrypting
.theme(&theme)
.run()?;
ev.value = Some(value);
}
}View on GitHub (pinned to 6f52dcdf99)
Solutions
- List everything currently defined to confirm the exact key: `mise set` (no arguments)
- Check all config layers involved: `mise config ls`, and query the specific file with `mise set --file <path> KEY`
- If it should exist, define it first: `mise set FOO=bar`
- If you meant the shell's environment variable, use `echo $FOO` — mise set only reads mise-managed env
Example fix
# before mise set DATABASE_URL # Environment variable DATABASE_URL not found # after mise set # list keys to confirm spelling mise set --file mise.local.toml DATABASE_URL # or query the file that defines it
Defensive patterns
Strategy: validation
Validate before calling
# confirm the key exists in mise's env before reading it
key=FOO
if mise set 2>/dev/null | awk 'NR>3 {print $1}' | grep -qx "$key"; then
val=$(mise set "$key")
else
echo "$key not defined in mise config env" >&2
fi Type guard
mise_env_has() { mise set 2>/dev/null | awk '{print $1}' | grep -qx "$1"; } Try / catch
Check `mise set KEY` exit code and stderr; 'not found' means the key is absent from mise config env — fall back to a default or fail with a clear message rather than retrying.
Prevention
- Use `mise set` (no args) to inventory available keys before scripting reads
- Remember this reads mise config env, not process env — use $VAR for the latter
- Keep env keys in one known config layer to make lookups predictable
When it happens
Trigger: Running `mise set FOO` when FOO is not defined in any loaded mise.toml [env] table (global, project, or local), or when FOO exists only as an OS/shell environment variable rather than a mise env entry.
Common situations: Typos in the key name; expecting `mise set KEY` to read the shell environment (use `echo $KEY` instead); the variable living in a different config file or config layer than the one currently trusted/loaded.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Environment variable {} not found
- --stdin requires exactly one environment variable key
- --stdin reads the value from stdin; do not provide a value w
- Setting [{}] is not set
- Unknown setting: {}
AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22).
Data as JSON: /api/errors/87dd4b673e2492b2.
Report an issue: GitHub.