{"record":{"id":"a915be16d98afd6e","repo":"emilk/egui","slug":"failed-to-create-temp-file","errorCode":null,"errorMessage":"Failed to create temp file","messagePattern":"Failed to create temp file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/egui_kittest/src/snapshot.rs","lineNumber":809,"sourceCode":"    }\n\n    /// Render a snapshot, save it to a temp file and open it in the default image viewer.\n    ///\n    /// This method is marked as deprecated to trigger errors in CI (so that it's not accidentally\n    /// committed).\n    #[deprecated = \"Only for debugging, don't commit this.\"]\n    #[cfg(not(target_arch = \"wasm32\"))]\n    pub fn debug_open_snapshot(&mut self) {\n        let image = self\n            .render()\n            .map_err(|err| SnapshotError::RenderError { err })\n            .unwrap();\n        let temp_file = tempfile::Builder::new()\n            .disable_cleanup(true) // we keep the file so it's accessible even after the test ends\n            .prefix(\"kittest-snapshot\")\n            .suffix(\".png\")\n            .tempfile()\n            .expect(\"Failed to create temp file\");\n\n        let path = temp_file.path();\n\n        image\n            .save(temp_file.path())\n            .map_err(|err| SnapshotError::WriteSnapshot {\n                err,\n                path: path.to_path_buf(),\n            })\n            .unwrap();\n\n        // Close temp file so it isn't locked when `open` tries to launch it (on Windows)\n        let path = temp_file.into_temp_path();\n\n        #[expect(clippy::print_stdout)]\n        {\n            println!(\"Wrote debug snapshot to: {}\", path.display());\n        }","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/emilk/egui/blob/b9a0723d88dee87ba0965470b554a6efdab1d0bb/crates/egui_kittest/src/snapshot.rs#L791-L827","documentation":"Error \"Failed to create temp file\" thrown in emilk/egui.","triggerScenarios":"Thrown at crates/egui_kittest/src/snapshot.rs:809 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":"std::env::set_var(\"TMPDIR\", \"/writable/tmp\"); // before running snapshot tests","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b9a0723d88dee87ba0965470b554a6efdab1d0bb","analyzedAt":"2026-08-19T12:39:57.743Z","contentChangedAt":"2026-08-19T12:39:57.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}