zed-industries/zed · error

Path is not absolute: {:?}

Error message

Path is not absolute: {:?}

What it means

AbsPath::new rejected the input because the given Path does not start from the filesystem root — a relative path was supplied where an absolute path invariant is required. The offending path is printed. This is a validation guard protecting the AbsPath type's core invariant.

Source

Thrown at crates/path/src/abs_path.rs:23

    path::{Path, PathBuf},
    rc::Rc,
    sync::Arc,
};

use anyhow::Context;

use crate::{PathStyle, rel_path::RelPath};

// An absolute path on the user's local filesystem.
// Requires paths to be valid utf-8
#[derive(PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
#[repr(transparent)]
pub struct AbsPath(Path);

impl AbsPath {
    pub fn new(path: &Path) -> anyhow::Result<&Self> {
        if !path.is_absolute() {
            return Err(anyhow::anyhow!("Path is not absolute: {:?}", path));
        }
        if path.to_str().is_none() {
            return Err(anyhow::anyhow!("Path is not valid utf-8: {:?}", path));
        }
        Ok(Self::new_unchecked(path))
    }

    fn new_unchecked(path: &Path) -> &Self {
        // SAFETY: `AbsPath` is a `repr(transparent)` wrapper around `Path`.
        unsafe { &*(path as *const Path as *const Self) }
    }

    pub fn to_abs_path_buf(&self) -> AbsPathBuf {
        AbsPathBuf(self.0.to_owned())
    }

    pub fn join(&self, name: impl AsRef<str>) -> AbsPathBuf {
        AbsPathBuf(self.0.join(name.as_ref()))

View on GitHub (pinned to f4178619ac)

Solutions

  1. Convert the path to absolute first, e.g. with std::fs::canonicalize or path_absolutize, before constructing an AbsPath
  2. Trace the caller to find why a user- or config-supplied relative path reached this API
  3. For CLI/config inputs, resolve relative paths against the intended base directory early
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/path/src/abs_path.rs:23 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/ed538ce77558bc4d. Report an issue: GitHub.