{"record":{"id":"1349d6d02755971b","repo":"zed-industries/zed","slug":"path-is-not-valid-utf-8","errorCode":null,"errorMessage":"Path is not valid utf-8: {:?}","messagePattern":"Path is not valid utf-8: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/path/src/abs_path.rs","lineNumber":26,"sourceCode":"};\n\nuse anyhow::Context;\n\nuse crate::{PathStyle, rel_path::RelPath};\n\n// An absolute path on the user's local filesystem.\n// Requires paths to be valid utf-8\n#[derive(PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]\n#[repr(transparent)]\npub struct AbsPath(Path);\n\nimpl AbsPath {\n    pub fn new(path: &Path) -> anyhow::Result<&Self> {\n        if !path.is_absolute() {\n            return Err(anyhow::anyhow!(\"Path is not absolute: {:?}\", path));\n        }\n        if path.to_str().is_none() {\n            return Err(anyhow::anyhow!(\"Path is not valid utf-8: {:?}\", path));\n        }\n        Ok(Self::new_unchecked(path))\n    }\n\n    fn new_unchecked(path: &Path) -> &Self {\n        // SAFETY: `AbsPath` is a `repr(transparent)` wrapper around `Path`.\n        unsafe { &*(path as *const Path as *const Self) }\n    }\n\n    pub fn to_abs_path_buf(&self) -> AbsPathBuf {\n        AbsPathBuf(self.0.to_owned())\n    }\n\n    pub fn join(&self, name: impl AsRef<str>) -> AbsPathBuf {\n        AbsPathBuf(self.0.join(name.as_ref()))\n    }\n\n    pub fn join_rel_path(&self, relative_path: &RelPath) -> AbsPathBuf {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/path/src/abs_path.rs#L8-L44","documentation":"AbsPath::new rejected the input because the path contains bytes that are not valid UTF-8 (to_str returned None). AbsPath requires valid UTF-8 by design, so non-UTF-8 paths from the OS cannot be represented; the raw path is printed via Debug.","triggerScenarios":"Thrown at crates/path/src/abs_path.rs:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Find the source of the non-UTF-8 path (often a file created with a legacy locale encoding) and rename it to a UTF-8 name","If the path comes from config or user input, validate/normalize the encoding before use","On Unix, convert using to_string_lossy only if losing bytes is acceptable for the use case"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}