{"record":{"id":"fc0ec63a21c1b0c5","repo":"pot-app/pot-desktop","slug":"get-cache-dir-failed-fc0ec6","errorCode":null,"errorMessage":"Get Cache Dir Failed","messagePattern":"Get Cache Dir Failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/system_ocr.rs","lineNumber":12,"sourceCode":"use dirs::cache_dir;\n\n#[tauri::command(async)]\n#[cfg(target_os = \"windows\")]\npub fn system_ocr(app_handle: tauri::AppHandle, lang: &str) -> Result<String, String> {\n    use windows::core::HSTRING;\n    use windows::Globalization::Language;\n    use windows::Graphics::Imaging::BitmapDecoder;\n    use windows::Media::Ocr::OcrEngine;\n    use windows::Storage::{FileAccessMode, StorageFile};\n\n    let mut app_cache_dir_path = cache_dir().expect(\"Get Cache Dir Failed\");\n    app_cache_dir_path.push(&app_handle.config().tauri.bundle.identifier);\n    app_cache_dir_path.push(\"pot_screenshot_cut.png\");\n\n    let path = app_cache_dir_path.to_string_lossy().replace(\"\\\\\\\\?\\\\\", \"\");\n\n    let file = StorageFile::GetFileFromPathAsync(&HSTRING::from(path))\n        .unwrap()\n        .get()\n        .unwrap();\n\n    let bitmap = BitmapDecoder::CreateWithIdAsync(\n        BitmapDecoder::PngDecoderId().unwrap(),\n        &file.OpenAsync(FileAccessMode::Read).unwrap().get().unwrap(),\n    )\n    .unwrap()\n    .get()\n    .unwrap();\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src-tauri/src/system_ocr.rs#L1-L30","documentation":"In the Windows-only system_ocr command, dirs::cache_dir() returned None and .expect('Get Cache Dir Failed') panicked before OCR can read the screenshot cut image. The system provides no cache directory (e.g. corrupted or missing user profile/environment), so the path to pot_screenshot_cut.png cannot be resolved.","triggerScenarios":"Thrown at src-tauri/src/system_ocr.rs:12 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the Windows user profile and LOCALAPPDATA environment variable are set correctly","Fall back to std::env::temp_dir() when cache_dir() is None","Change the command to return Result<String, String> and report the error to the frontend rather than panicking"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"594d32ede96acd106b0256deaa8bb440ffcdff40","analyzedAt":"2026-09-02T18:12:21.811Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}