{"record":{"id":"b05273f954608838","repo":"pot-app/pot-desktop","slug":"get-cache-dir-failed-b05273","errorCode":null,"errorMessage":"Get Cache Dir Failed","messagePattern":"Get Cache Dir Failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/window.rs","lineNumber":339,"sourceCode":"    {\n        let monitor = window.current_monitor().unwrap().unwrap();\n        let size = monitor.size();\n        window.set_decorations(false).unwrap();\n        window.set_size(*size).unwrap();\n    }\n\n    #[cfg(not(target_os = \"macos\"))]\n    window.set_fullscreen(true).unwrap();\n\n    window.set_always_on_top(true).unwrap();\n    window\n}\n\npub fn ocr_recognize() {\n    #[cfg(target_os = \"macos\")]\n    {\n        let app_handle = APP.get().unwrap();\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        if !app_cache_dir_path.exists() {\n            // 创建目录\n            fs::create_dir_all(&app_cache_dir_path).expect(\"Create Cache Dir Failed\");\n        }\n        app_cache_dir_path.push(\"pot_screenshot_cut.png\");\n\n        let path = app_cache_dir_path.to_string_lossy().replace(\"\\\\\\\\?\\\\\", \"\");\n        println!(\"Screenshot path: {}\", path);\n        if let Ok(_output) = std::process::Command::new(\"/usr/sbin/screencapture\")\n            .arg(\"-i\")\n            .arg(\"-r\")\n            .arg(path)\n            .output()\n        {\n            recognize_window();\n        }\n    }","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src-tauri/src/window.rs#L321-L357","documentation":"In the macOS branch of ocr_recognize(), dirs::cache_dir() returned None and .expect('Get Cache Dir Failed') panicked. Without a cache directory the app cannot store/read the screenshot cut used for OCR, so OCR recognition cannot proceed; this fires when the OS gives no user cache path (unusual HOME/library configuration).","triggerScenarios":"Thrown at src-tauri/src/window.rs:339 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure HOME is set and the user Library/Caches location is accessible on macOS","Use std::env::temp_dir() or dirs::home_dir().join(\"Library/Caches\") as a fallback","Refactor to propagate a Result and notify the caller (handle_ocr_recognize/tray handlers) instead of 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"}