emilk/egui · error
Failed to create temp file
Error message
Failed to create temp file
What it means
Error "Failed to create temp file" thrown in emilk/egui.
Source
Thrown at crates/egui_kittest/src/snapshot.rs:809
}
/// Render a snapshot, save it to a temp file and open it in the default image viewer.
///
/// This method is marked as deprecated to trigger errors in CI (so that it's not accidentally
/// committed).
#[deprecated = "Only for debugging, don't commit this."]
#[cfg(not(target_arch = "wasm32"))]
pub fn debug_open_snapshot(&mut self) {
let image = self
.render()
.map_err(|err| SnapshotError::RenderError { err })
.unwrap();
let temp_file = tempfile::Builder::new()
.disable_cleanup(true) // we keep the file so it's accessible even after the test ends
.prefix("kittest-snapshot")
.suffix(".png")
.tempfile()
.expect("Failed to create temp file");
let path = temp_file.path();
image
.save(temp_file.path())
.map_err(|err| SnapshotError::WriteSnapshot {
err,
path: path.to_path_buf(),
})
.unwrap();
// Close temp file so it isn't locked when `open` tries to launch it (on Windows)
let path = temp_file.into_temp_path();
#[expect(clippy::print_stdout)]
{
println!("Wrote debug snapshot to: {}", path.display());
}View on GitHub (pinned to b9a0723d88)
Solutions
- The temp directory is missing or not writable: set TMPDIR (or platform temp dir) to a writable location before running snapshot tests.
- Ensure there is free disk space for the temporary screenshot file.
Example fix
std::env::set_var("TMPDIR", "/writable/tmp"); // before running snapshot tests When it happens
Trigger: Thrown at crates/egui_kittest/src/snapshot.rs:809 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of emilk/egui@b9a0723d88 (2026-08-19).
Data as JSON: /api/errors/a915be16d98afd6e.
Report an issue: GitHub.