zed-industries/zed · error
path is not relative: {result:?}
Error message
path is not relative: {result:?} What it means
After normalization, RelPath::new determined the resulting path still escapes its invariants — normalization of '.' and '..' components would climb above the root or leave an invalid relative form. The offending normalized result is printed; typically the input contained a leading or excess '..'.
Source
Thrown at crates/path/src/rel_path.rs:101
}
let mut result = match string {
Cow::Borrowed(string) => Cow::Borrowed(Self::from_str(string)),
Cow::Owned(string) => Cow::Owned(RelPathBuf(string)),
};
if result
.components()
.any(|component| component == "" || component == "." || component == "..")
{
let mut normalized = RelPathBuf::new();
for component in result.components() {
match component {
"" => {}
"." => {}
".." => {
if !normalized.pop() {
return Err(anyhow!("path is not relative: {result:?}"));
}
}
other => normalized.push(RelPath::from_str(other)),
}
}
result = Cow::Owned(normalized)
}
Ok(result)
}
#[track_caller]
pub fn new_test<'a>(path: &'a str) -> Cow<'a, Self> {
Self::new(Path::new(path), PathStyle::Unix).unwrap()
}
/// Converts a path that is already normalized and uses '/' separators
/// into a [`RelPath`] .View on GitHub (pinned to f4178619ac)
Solutions
- Remove leading '..' components from the input; a RelPath must stay within its base
- Reject or sanitize user-supplied relative paths that traverse above the root
- If reading from storage, audit writes that allowed un-normalized paths to be persisted
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/path/src/rel_path.rs:101 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/11767fb0800c65df.
Report an issue: GitHub.