pot-app/pot-desktop · error
Get Cache Dir Failed
Error message
Get Cache Dir Failed
What it means
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).
Source
Thrown at src-tauri/src/window.rs:339
{
let monitor = window.current_monitor().unwrap().unwrap();
let size = monitor.size();
window.set_decorations(false).unwrap();
window.set_size(*size).unwrap();
}
#[cfg(not(target_os = "macos"))]
window.set_fullscreen(true).unwrap();
window.set_always_on_top(true).unwrap();
window
}
pub fn ocr_recognize() {
#[cfg(target_os = "macos")]
{
let app_handle = APP.get().unwrap();
let mut app_cache_dir_path = cache_dir().expect("Get Cache Dir Failed");
app_cache_dir_path.push(&app_handle.config().tauri.bundle.identifier);
if !app_cache_dir_path.exists() {
// 创建目录
fs::create_dir_all(&app_cache_dir_path).expect("Create Cache Dir Failed");
}
app_cache_dir_path.push("pot_screenshot_cut.png");
let path = app_cache_dir_path.to_string_lossy().replace("\\\\?\\", "");
println!("Screenshot path: {}", path);
if let Ok(_output) = std::process::Command::new("/usr/sbin/screencapture")
.arg("-i")
.arg("-r")
.arg(path)
.output()
{
recognize_window();
}
}View on GitHub (pinned to 594d32ede9)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src-tauri/src/window.rs:339 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pot-app/pot-desktop@594d32ede9 (2026-09-02).
Data as JSON: /api/errors/b05273f954608838.
Report an issue: GitHub.