pot-app/pot-desktop · error

Create Cache Dir Failed

Error message

Create Cache Dir Failed

What it means

In the macOS branch of ocr_recognize(), fs::create_dir_all on <cache_dir>/<bundle.identifier> returned Err and .expect('Create Cache Dir Failed') panicked, so the directory needed for the OCR screenshot cut could not be created — usually caused by permissions, a read-only volume, or a non-directory file at the target path.

Source

Thrown at src-tauri/src/window.rs:343

        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();
        }
    }
    #[cfg(not(target_os = "macos"))]
    {
        let window = screenshot_window();
        let window_ = window.clone();

View on GitHub (pinned to 594d32ede9)

Solutions

  1. Check permissions and existence of the cache directory path on macOS
  2. Remove any regular file occupying the target path
  3. Match on the io::Error and return/report it instead of panicking
  4. Fall back to a temporary directory when creation fails
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src-tauri/src/window.rs:343 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/a86db64a38554536. Report an issue: GitHub.