zed-industries/zed · error
absolute path not allowed: {path:?}
Error message
absolute path not allowed: {path:?} What it means
RelPath::new rejected the input because, after stripping leading './' prefixes and trailing separators, the remaining string still looks absolute (e.g. starts with '/' or a Windows drive prefix). RelPath's invariant is that it names something under a worktree root, so absolute paths are forbidden.
Source
Thrown at crates/path/src/rel_path.rs:77
pub fn new<'a>(path: &'a Path, path_style: PathStyle) -> Result<Cow<'a, Self>> {
let mut path = path.to_str().context("non utf-8 path")?;
let (prefixes, suffixes): (&[_], &[_]) = match path_style {
PathStyle::Unix => (&["./"], &['/']),
PathStyle::Windows => (&["./", ".\\"], &['/', '\\']),
};
while prefixes.iter().any(|prefix| path.starts_with(prefix)) {
path = &path[prefixes[0].len()..];
}
while let Some(prefix) = path.strip_suffix(suffixes)
&& !prefix.is_empty()
{
path = prefix;
}
if is_absolute(&path, path_style) {
return Err(anyhow!("absolute path not allowed: {path:?}"));
}
let mut string = Cow::Borrowed(path);
if path_style == PathStyle::Windows && path.contains('\\') {
string = Cow::Owned(string.as_ref().replace('\\', "/"))
}
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() {View on GitHub (pinned to f4178619ac)
Solutions
- Strip the absolute prefix before constructing the RelPath — usually by making the path relative to the worktree root
- Check PathStyle handling on Windows, where both '/' and '\' roots and drive letters must be removed
- Validate persisted relative paths (settings, databases) for absolute entries that may have leaked in
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/path/src/rel_path.rs:77 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/ae4959aceca03038.
Report an issue: GitHub.