zed-industries/zed · error

failed to determine cachesDirectory directory

Error message

failed to determine cachesDirectory directory

What it means

temp_dir() panics while initializing the static temp path cache because dirs::cache_dir() (macOS branch, cachesDirectory) returned None. The OS could not locate the user's cache directory (e.g. missing/unresolvable HOME or XDG environment on that platform).

Source

Thrown at crates/paths/src/paths.rs:198

                dirs::state_dir().expect("failed to determine XDG_STATE_HOME directory")
            }
            .join(APP_NAME_LOWERCASE);
        } else {
            // Windows
            return dirs::data_local_dir()
                .expect("failed to determine LocalAppData directory")
                .join(APP_NAME);
        }
    })
}

/// Returns the path to the temp directory used by Zed.
pub fn temp_dir() -> &'static PathBuf {
    static TEMP_DIR: OnceLock<PathBuf> = OnceLock::new();
    TEMP_DIR.get_or_init(|| {
        if cfg!(target_os = "macos") {
            return dirs::cache_dir()
                .expect("failed to determine cachesDirectory directory")
                .join(APP_NAME);
        }

        if cfg!(target_os = "windows") {
            return dirs::cache_dir()
                .expect("failed to determine LocalAppData directory")
                .join(APP_NAME);
        }

        if cfg!(any(target_os = "linux", target_os = "freebsd")) {
            return if let Ok(flatpak_xdg_cache) = std::env::var("FLATPAK_XDG_CACHE_HOME") {
                flatpak_xdg_cache.into()
            } else {
                dirs::cache_dir().expect("failed to determine XDG_CACHE_HOME directory")
            }
            .join(APP_NAME_LOWERCASE);
        }

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure the user environment resolves a cache directory (valid HOME on macOS, not running in a stripped environment)
  2. Run Zed as a normal user session with standard macOS directory services
  3. Wrap initialization to fall back to std::env::temp_dir() when dirs::cache_dir() returns None
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/paths/src/paths.rs:198 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/515dfa129b3d7a8f. Report an issue: GitHub.