zed-industries/zed · error
failed to determine XDG_DATA_HOME directory
Error message
failed to determine XDG_DATA_HOME directory
What it means
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.
Source
Thrown at crates/paths/src/paths.rs:156
home_dir().join(".config").join(APP_NAME_LOWERCASE)
}
})
}
/// 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);
}View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/paths/src/paths.rs:156 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/79b201d25a7960d5.
Report an issue: GitHub.