emilk/egui · error
Unsupported value for UPDATE_SNAPSHOTS: {unknown:?}
Error message
Unsupported value for UPDATE_SNAPSHOTS: {unknown:?} What it means
The UPDATE_SNAPSHOTS environment variable controls snapshot behavior (Test, UpdateFailing, UpdateAll). SnapshotOptions::from_env parses known string values and panics on anything unrecognized, refusing to guess the developer's intent. Only "false"/"0"/"no"/"off", "true"/"1"/"yes"/"on", and "force" are accepted.
Source
Thrown at crates/egui_kittest/src/snapshot.rs:400
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Mode {
Test,
UpdateFailing,
UpdateAll,
}
impl Mode {
fn from_env() -> Self {
let Ok(value) = std::env::var("UPDATE_SNAPSHOTS") else {
return Self::Test;
};
match value.as_str() {
"false" | "0" | "no" | "off" => Self::Test,
"true" | "1" | "yes" | "on" => Self::UpdateFailing,
"force" => Self::UpdateAll,
unknown => {
panic!("Unsupported value for UPDATE_SNAPSHOTS: {unknown:?}");
}
}
}
fn is_update(&self) -> bool {
match self {
Self::Test => false,
Self::UpdateFailing | Self::UpdateAll => true,
}
}
}
/// Image snapshot test with custom options.
///
/// If you want to change the default options for your whole project, it's recommended to create a
/// new `my_image_snapshot` function in your project that calls this function with the desired options.
/// You could additionally use the
/// [disallowed_methods](https://rust-lang.github.io/rust-clippy/master/#disallowed_methods)View on GitHub (pinned to 441971a776)
Solutions
- Set UPDATE_SNAPSHOTS to one of: false/0/no/off, true/1/yes/on, or force
- Check for stray whitespace, quotes, or casing in your env var definition (echo "$UPDATE_SNAPSHOTS" | cat -A)
- In CI, fix the workflow env block or command-line prefix to use an exact accepted value
- Unset the variable entirely to use the default (Test) mode
Example fix
// before UPDATE_SNAPSHOTS=all cargo test // after UPDATE_SNAPSHOTS=force cargo test
Defensive patterns
Strategy: validation
Validate before calling
const VALID: [&str; 12] = ["false","0","no","off","true","1","yes","on","force"];
let v = std::env::var("UPDATE_SNAPSHOTS").unwrap_or_default();
assert!(v.is_empty() || VALID.contains(&v.as_str()), "UPDATE_SNAPSHOTS must be one of {VALID:?}, got {v:?}"); Try / catch
// from_env panics; validate the value in CI before cargo test
match std::env::var("UPDATE_SNAPSHOTS") {
Ok(v) if !["false","0","no","off","true","1","yes","on","force"].contains(&v.as_str()) => {
panic!("fix UPDATE_SNAPSHOTS={v:?}: allowed values are false/0/no/off, true/1/yes/on, force");
}
_ => {}
} Prevention
- Use the exact lowercase accepted values in CI config and shell scripts
- Quote env values carefully in shell to avoid trailing whitespace
- Do not copy env var values from other snapshot-testing libraries
- Add a CI lint step that validates UPDATE_SNAPSHOTS before running tests
When it happens
Trigger: Setting UPDATE_SNAPSHOTS to any string outside the accepted set — e.g. UPDATE_SNAPSHOTS=yes\ (trailing whitespace), "YES" (case sensitivity), "update", "all", or "True" — before running kittest-based tests.
Common situations: Typo'd or case-mismatched env values in CI configuration; copying "UPDATE_SNAPSHOTS=all" from another snapshot library's docs; shell quoting errors introducing stray whitespace or quotes into the value.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- {err}
- {err}
- Harness::ui_id is only available for harnesses built with a
- {}
- Multiple SnapshotResults were dropped without being handled
AI-assisted analysis of emilk/egui@441971a776 (2026-09-12).
Data as JSON: /api/errors/b4ef5cb6d8eb3b49.
Report an issue: GitHub.