zed-industries/zed · error

failed to determine LocalAppData directory

Error message

failed to determine LocalAppData directory

What it means

Panic on Windows when dirs' local-app-data lookup returns None while computing the data directory: the LocalAppData known folder cannot be resolved (broken User Shell Folders registry value or non-standard environment), so there is no base path for Zed's databases, extensions, and logs.

Source

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

/// Returns the path to the data directory used by Zed.
pub fn data_dir() -> &'static PathBuf {
    CURRENT_DATA_DIR.get_or_init(|| {
        if let Some(custom_dir) = CUSTOM_DATA_DIR.get() {
            custom_dir.clone()
        } else if cfg!(target_os = "macos") {
            home_dir()
                .join("Library/Application Support")
                .join(APP_NAME)
        } else if cfg!(any(target_os = "linux", target_os = "freebsd")) {
            if let Ok(flatpak_xdg_data) = std::env::var("FLATPAK_XDG_DATA_HOME") {
                flatpak_xdg_data.into()
            } else {
                dirs::data_local_dir().expect("failed to determine XDG_DATA_HOME directory")
            }
            .join(APP_NAME_LOWERCASE)
        } else if cfg!(target_os = "windows") {
            dirs::data_local_dir()
                .expect("failed to determine LocalAppData directory")
                .join(APP_NAME)
        } else {
            config_dir().clone() // Fallback
        }
    })
}

pub fn state_dir() -> &'static PathBuf {
    static STATE_DIR: OnceLock<PathBuf> = OnceLock::new();
    STATE_DIR.get_or_init(|| {
        if cfg!(target_os = "macos") {
            return home_dir().join(".local").join("state").join(APP_NAME);
        }

        if cfg!(any(target_os = "linux", target_os = "freebsd")) {
            return if let Ok(flatpak_xdg_state) = std::env::var("FLATPAK_XDG_STATE_HOME") {
                flatpak_xdg_state.into()
            } else {

View on GitHub (pinned to f4178619ac)

Solutions

  1. Check that the Local AppData shell folder resolves (registry User Shell Folders / %LOCALAPPDATA%)
  2. Supply a custom data directory to bypass platform detection
  3. Fall back to the roaming config base or home dir rather than panicking
Defensive patterns

Strategy: fallback

When it happens

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