zed-industries/zed · error

Path must be relative: {right:?}

Error message

Path must be relative: {right:?}

What it means

join_path's internal join returned None because the right-hand path is not relative — it is absolute (or otherwise cannot be appended under `left`). The guard enforces that only relative paths may be joined onto a base directory path.

Source

Thrown at crates/path/src/path.rs:124

        }
    }

    pub fn join_path(
        self,
        left: impl AsRef<Path>,
        right: impl AsRef<Path>,
    ) -> anyhow::Result<PathBuf> {
        let left = left
            .as_ref()
            .to_str()
            .ok_or_else(|| anyhow::anyhow!("Path contains invalid UTF-8"))?;
        let right = right.as_ref();
        let right_string = right
            .to_str()
            .ok_or_else(|| anyhow::anyhow!("Path contains invalid UTF-8"))?;
        let joined = self
            .join(left, right_string)
            .ok_or_else(|| anyhow::anyhow!("Path must be relative: {right:?}"))?;
        Ok(PathBuf::from(self.normalize(&joined)))
    }

    pub fn join_path_preserving_components(
        self,
        left: impl AsRef<Path>,
        right: impl AsRef<Path>,
    ) -> anyhow::Result<PathBuf> {
        let left = left
            .as_ref()
            .to_str()
            .ok_or_else(|| anyhow::anyhow!("Path contains invalid UTF-8"))?;
        let right = right.as_ref();
        let right_string = right
            .to_str()
            .ok_or_else(|| anyhow::anyhow!("Path contains invalid UTF-8"))?;
        let joined = self
            .join(left, right_string)

View on GitHub (pinned to f4178619ac)

Solutions

  1. Strip the leading separator or prefix from the right-hand path before joining, e.g. via strip_prefix or path helpers
  2. Validate user-supplied sub-paths early and reject absolute components
  3. Check callers like worktrees_directory_for_repo for accidentally absolute computed sub-paths
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/path/src/path.rs:124 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/4d1439a29bc45742. Report an issue: GitHub.