{"record":{"id":"e81074c1de15c5f4","repo":"zed-industries/zed","slug":"failed-to-determine-xdg-state-home-directory","errorCode":null,"errorMessage":"failed to determine XDG_STATE_HOME directory","messagePattern":"failed to determine XDG_STATE_HOME directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/paths/src/paths.rs","lineNumber":180,"sourceCode":"                .join(APP_NAME)\n        } else {\n            config_dir().clone() // Fallback\n        }\n    })\n}\n\npub fn state_dir() -> &'static PathBuf {\n    static STATE_DIR: OnceLock<PathBuf> = OnceLock::new();\n    STATE_DIR.get_or_init(|| {\n        if cfg!(target_os = \"macos\") {\n            return home_dir().join(\".local\").join(\"state\").join(APP_NAME);\n        }\n\n        if cfg!(any(target_os = \"linux\", target_os = \"freebsd\")) {\n            return if let Ok(flatpak_xdg_state) = std::env::var(\"FLATPAK_XDG_STATE_HOME\") {\n                flatpak_xdg_state.into()\n            } else {\n                dirs::state_dir().expect(\"failed to determine XDG_STATE_HOME directory\")\n            }\n            .join(APP_NAME_LOWERCASE);\n        } else {\n            // Windows\n            return dirs::data_local_dir()\n                .expect(\"failed to determine LocalAppData directory\")\n                .join(APP_NAME);\n        }\n    })\n}\n\n/// Returns the path to the temp directory used by Zed.\npub fn temp_dir() -> &'static PathBuf {\n    static TEMP_DIR: OnceLock<PathBuf> = OnceLock::new();\n    TEMP_DIR.get_or_init(|| {\n        if cfg!(target_os = \"macos\") {\n            return dirs::cache_dir()\n                .expect(\"failed to determine cachesDirectory directory\")","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/paths/src/paths.rs#L162-L198","documentation":"Panic when the state directory base cannot be determined on Linux/BSD: FLATPAK_XDG_STATE_HOME/XDG_STATE_HOME is not usable and no home directory exists (HOME unset), so the ~/.local/state/zed path (used for runtime state) cannot be formed. Note state_dir has its own OnceLock, so a panic here poisons only state-dir consumers.","triggerScenarios":"Thrown at crates/paths/src/paths.rs:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set HOME or an absolute XDG_STATE_HOME in the environment","Under Flatpak, ensure FLATPAK_XDG_STATE_HOME is exported to the sandbox","Return an error (or fall back to config_dir as the comment suggests) instead of unwrapping"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}