zed-industries/zed · error

Path contains invalid UTF-8

Error message

Path contains invalid UTF-8

What it means

In join_path, the left-hand path could not be converted to a UTF-8 string (to_str returned None), so it cannot be joined under the platform's path rules. Some component of the base path contains non-UTF-8 bytes, which this API does not support.

Source

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

                "{left}{}{right}",
                if left.ends_with(self.primary_separator()) {
                    ""
                } else {
                    self.primary_separator()
                }
            ))
        }
    }

    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()

View on GitHub (pinned to f4178619ac)

Solutions

  1. Identify and fix the non-UTF-8 component in the base path (rename the file or directory)
  2. Ensure callers pass paths already validated as UTF-8, e.g. by converting through AbsPath first
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/path/src/path.rs:117 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/051c913ccf9723f5. Report an issue: GitHub.