{"record":{"id":"79b201d25a7960d5","repo":"zed-industries/zed","slug":"failed-to-determine-xdg-data-home-directory","errorCode":null,"errorMessage":"failed to determine XDG_DATA_HOME directory","messagePattern":"failed to determine XDG_DATA_HOME directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/paths/src/paths.rs","lineNumber":156,"sourceCode":"            home_dir().join(\".config\").join(APP_NAME_LOWERCASE)\n        }\n    })\n}\n\n/// Returns the path to the data directory used by Zed.\npub fn data_dir() -> &'static PathBuf {\n    CURRENT_DATA_DIR.get_or_init(|| {\n        if let Some(custom_dir) = CUSTOM_DATA_DIR.get() {\n            custom_dir.clone()\n        } else if cfg!(target_os = \"macos\") {\n            home_dir()\n                .join(\"Library/Application Support\")\n                .join(APP_NAME)\n        } else if cfg!(any(target_os = \"linux\", target_os = \"freebsd\")) {\n            if let Ok(flatpak_xdg_data) = std::env::var(\"FLATPAK_XDG_DATA_HOME\") {\n                flatpak_xdg_data.into()\n            } else {\n                dirs::data_local_dir().expect(\"failed to determine XDG_DATA_HOME directory\")\n            }\n            .join(APP_NAME_LOWERCASE)\n        } else if cfg!(target_os = \"windows\") {\n            dirs::data_local_dir()\n                .expect(\"failed to determine LocalAppData directory\")\n                .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        }","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/paths/src/paths.rs#L138-L174","documentation":"Panic on Linux/BSD when the data directory base is unavailable: XDG_DATA_HOME (or FLATPAK_XDG_DATA_HOME) is not usable and the home directory could not be determined (HOME unset, no passwd entry). Without a base, the ~/.local/share/zed path cannot be constructed for databases, extensions, and logs.","triggerScenarios":"Thrown at crates/paths/src/paths.rs:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set HOME or an absolute XDG_DATA_HOME in the environment","Use set_custom_data_dir/ZED_CUSTOM_DATA_DIR to supply the data root explicitly","Return an error instead of unwrapping so startup can report the missing environment"],"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"}