pot-app/pot-desktop · error
Create Cache Dir Failed
Error message
Create Cache Dir Failed
What it means
In screenshot, after building the app cache path (<cache_dir>/<bundle.identifier>), fs::create_dir_all failed (returned Err) and .expect('Create Cache Dir Failed') panicked. This means the directory could not be created — typically a permissions problem, a read-only filesystem, or a non-directory file already occupying that path — so the screenshot file cannot be written.
Source
Thrown at src-tauri/src/screenshot.rs:20
#[tauri::command]
pub fn screenshot(x: i32, y: i32) {
use crate::APP;
use dirs::cache_dir;
use screenshots::{Compression, Screen};
use std::fs;
info!("Screenshot screen with position: x={}, y={}", x, y);
let screens = Screen::all().unwrap();
for screen in screens {
let info = screen.display_info;
info!("Screen: {:?}", info);
if info.x == x && info.y == y {
let handle = APP.get().unwrap();
let mut app_cache_dir_path = cache_dir().expect("Get Cache Dir Failed");
app_cache_dir_path.push(&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.png");
let image = screen.capture().unwrap();
let buffer = image.to_png(Compression::Fast).unwrap();
fs::write(app_cache_dir_path, buffer).unwrap();
break;
}
}
}
View on GitHub (pinned to 594d32ede9)
Solutions
- Check filesystem permissions on the cache directory and that it is writable by the app user
- Ensure no regular file exists at the target path that blocks directory creation
- Handle the io::Error (match on kind) and surface it to the frontend instead of panicking
- Fall back to a temp directory if the cache location is unusable
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src-tauri/src/screenshot.rs:20 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/e628e533ef79ef00.
Report an issue: GitHub.