zed-industries/zed · error

failed to determine XDG_CACHE_HOME directory

Error message

failed to determine XDG_CACHE_HOME directory

What it means

temp_dir() panics on the Linux/FreeBSD branch because the XDG_CACHE_HOME-derived cache dir lookup (dirs::cache_dir()) returned None, typically because HOME is unset or invalid in the environment launching Zed.

Source

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

    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);
        }

        home_dir().join(".cache").join(APP_NAME_LOWERCASE)
    })
}

/// Returns the path to the hang traces directory.
pub fn hang_traces_dir() -> &'static PathBuf {
    static LOGS_DIR: OnceLock<PathBuf> = OnceLock::new();
    LOGS_DIR.get_or_init(|| data_dir().join("hang_traces"))
}

/// Returns the path to the logs directory.
pub fn logs_dir() -> &'static PathBuf {
    static LOGS_DIR: OnceLock<PathBuf> = OnceLock::new();
    LOGS_DIR.get_or_init(|| {

View on GitHub (pinned to f4178619ac)

Solutions

  1. Set a valid HOME environment variable before launching Zed
  2. Ensure XDG_CACHE_HOME points to a writable directory if overridden
  3. Add a fallback to std::env::temp_dir() when dirs::cache_dir() is None
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/paths/src/paths.rs:212 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/bb5a94eaa789a6a0. Report an issue: GitHub.