jdx/mise · error
Environment variable
Error message
Environment variable {} not found What it means
`mise set get` (mise set --get / `mise set` with a key filter) looks up each requested key in the environment map computed from all config sources (`env_with_sources`), which already includes decrypted values. If a requested key is not present in any active config's [env] directives, mise aborts with this error instead of printing anything. It is a user-facing lookup failure indicating the variable simply is not defined in the current environment context.
Solutions
- Run `mise env` to list all environment variables mise actually manages and confirm the exact key name.
- Add the key to an [env] block in the appropriate mise.toml (or run `mise set KEY=value` to write it).
- Check you are in the project directory (or use --cd) so the config file defining the variable is loaded.
Example fix
// before: key not in any [env] mise set API_URL // error: Environment variable API_URL not found // after: define it first, then get [env] API_URL = "https://api.example.com" $ mise set API_URL
Defensive patterns
Strategy: validation
Validate before calling
if mise env | grep -qx 'API_URL=.*'; then mise set API_URL; else echo 'API_URL not managed by mise' >&2; fi
Try / catch
if ! value=$(mise set API_URL 2>/dev/null); then value="${API_URL_DEFAULT:-}"; fi Prevention
- Keep a canonical [env] block in mise.toml and reference keys from it
- Run `mise env` before scripting against managed variables
- Use mise.toml in the working directory (or --cd) so configs load
When it happens
Trigger: Running `mise set <key>` (get path) where `config.env_with_sources()` returns no entry for the requested key — e.g. the key is defined in a different mise environment/directory, was removed from mise.toml, or was never set.
Common situations: Typo in the variable name; variable defined only in a project-level mise.toml while running from another directory; variable removed by a teammate's config change; expecting a shell-exported variable to be managed by mise when it is not in any [env] block.
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
- bail!(msg) — dynamic message: uninstalled tool message from…
- cannot be set in a config file: mise reads it before config…
- provider ' ' is inactive
- a branch name is required
- a glob is required
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/5f58a6fbd47967e1.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/set.rs:305
None // Fall back to global config if no local config exists
}
}
} else {
None
};
let filter = self.env_vars.unwrap();
// Handle global config case first
if config_path.is_none() {
let config = Config::get().await?;
let env_with_sources = config.env_with_sources().await?;
// env_with_sources already contains decrypted values
for eva in filter {
if let Some((value, _source)) = env_with_sources.get(&eva.key) {
miseprintln!("{value}");
} else {
bail!("Environment variable {} not found", eva.key);
}
}
return Ok(());
}
// Get the config to access directives directly
let config = MiseToml::from_file(&config_path.unwrap()).unwrap_or_default();
// For local configs, check directives directly
let env_entries = config.env_entries()?;
for eva in filter {
match env_entries.iter().find_map(|ev| match ev {
EnvDirective::Val(k, v, _) if k == &eva.key => Some((v.clone(), Some(ev))),
EnvDirective::Age {
key: k, value: v, ..
} if k == &eva.key => Some((v.clone(), Some(ev))),
_ => None,
}) {View on GitHub (pinned to 533346cc37)