zed-industries/zed · error
invalid relative path {path:?}
Error message
invalid relative path {path:?} What it means
from_unix_str requires an already-normalized, '/'-separated relative path, and RelPath::new rejected the input (absolute path, empty/dot components, or '..' traversal). This is a strict validation helper: callers promise pre-normalized input, and this error means that promise was broken.
Source
Thrown at crates/path/src/rel_path.rs:127
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`] .
///
/// Returns an error if the path is not already in the correct format.
#[track_caller]
pub fn from_unix_str<S: AsRef<Path> + ?Sized>(path: &S) -> anyhow::Result<&Self> {
let path = path.as_ref();
match Self::new(path, PathStyle::Unix)? {
Cow::Borrowed(path) => Ok(path),
Cow::Owned(_) => Err(anyhow!("invalid relative path {path:?}")),
}
}
fn from_str(s: &str) -> &Self {
// Safety: `RelPath` is a transparent wrapper around `str`.
unsafe { &*(s as *const str as *const Self) }
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
pub fn components(&self) -> RelPathComponents<'_> {
RelPathComponents(&self.0)
}
pub fn ancestors(&self) -> RelPathAncestors<'_> {
RelPathAncestors {View on GitHub (pinned to f4178619ac)
Solutions
- Normalize the string before calling from_unix_str (resolve '.', '..', and empty segments)
- Ensure the input is actually relative and uses '/' separators, not the platform separator
- Audit callers that pass user or persisted data instead of trusted normalized paths
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/path/src/rel_path.rs:127 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/e0cf8038ca61aa06.
Report an issue: GitHub.