zed-industries/zed · error

failed to determine home directory

Error message

failed to determine home directory

What it means

home_dir() panics caching the home directory because dirs::home_dir() returned None — the process environment has no resolvable home directory (missing HOME/USERPROFILE), typically from running in a stripped or service environment.

Source

Thrown at crates/util/src/paths.rs:36

use path::rel_path::RelPathBuf;

pub use path::PathStyle;

/// Returns the path to the user's home directory.
#[cfg(not(target_family = "wasm"))]
pub fn home_dir() -> &'static PathBuf {
    static HOME_DIR: std::sync::OnceLock<PathBuf> = std::sync::OnceLock::new();
    HOME_DIR.get_or_init(|| {
        if cfg!(any(test, feature = "test-support")) {
            if cfg!(target_os = "macos") {
                PathBuf::from("/Users/zed")
            } else if cfg!(target_os = "windows") {
                PathBuf::from("C:\\Users\\zed")
            } else {
                PathBuf::from("/home/zed")
            }
        } else {
            dirs::home_dir().expect("failed to determine home directory")
        }
    })
}

pub trait PathExt {
    /// Compacts a given file path by replacing the user's home directory
    /// prefix with a tilde (`~`).
    ///
    /// # Returns
    ///
    /// * A `PathBuf` containing the compacted file path. If the input path
    ///   does not have the user's home directory prefix, or if we are not on
    ///   Linux or macOS, the original path is returned unchanged.
    fn compact(&self) -> PathBuf;

    /// Returns a file's extension or, if the file is hidden, its name without the leading dot
    fn extension_or_hidden_file_name(&self) -> Option<&str>;

View on GitHub (pinned to f4178619ac)

Solutions

  1. Set HOME (Unix) or USERPROFILE (Windows) before launching
  2. Fall back to std::env::temp_dir()-based path when home is unresolvable
  3. Avoid running Zed in environments without a user home
Defensive patterns

Strategy: fallback

When it happens

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