zed-industries/zed · error
Failed to convert {} to absolute path
Error message
Failed to convert {} to absolute path What it means
read_file first resolves its input to a ProjectPath, then asks Project::absolute_path to map it to a filesystem path. That mapping returns None when the owning worktree cannot produce an absolute path — typically because the worktree was removed from the project or is otherwise unreadable — and the tool aborts with this error before any settings or filesystem checks.
Source
Thrown at crates/agent/src/tools/read_file_tool.rs:298
let (project_path, symlink_canonical_target) =
project.read_with(cx, |project, cx| {
let resolved =
resolve_project_path(project, &input.path, &canonical_roots, cx)?;
anyhow::Ok(match resolved {
ResolvedProjectPath::Safe(path) => (path, None),
ResolvedProjectPath::SymlinkEscape {
project_path,
canonical_target,
} => (project_path, Some(canonical_target)),
})
}).map_err(tool_content_err)?;
let abs_path = project
.read_with(cx, |project, cx| {
project.absolute_path(&project_path, cx)
})
.ok_or_else(|| {
anyhow!("Failed to convert {} to absolute path", input.path)
}).map_err(tool_content_err)?;
// Check settings exclusions synchronously
project.read_with(cx, |_project, cx| {
let global_settings = WorktreeSettings::get_global(cx);
if global_settings.is_path_excluded(&project_path.path) {
anyhow::bail!(
"Cannot read file because its path matches the global `file_scan_exclusions` setting: {}",
input.path
);
}
if global_settings.is_path_private(&project_path.path) {
anyhow::bail!(
"Cannot read file because its path matches the global `private_files` setting: {}",
input.path
);
}View on GitHub (pinned to bc538def45)
Solutions
- Re-open the folder containing the file as a worktree in the project and retry
- Retry the request so path resolution runs against the current set of worktrees
- Open the file directly in the editor if agent access is not required
Defensive patterns
Strategy: validation
Validate before calling
let abs_path = project.read_with(cx, |project, cx| {
project.absolute_path(&project_path, cx)
});
if abs_path.is_none() {
// owning worktree is gone/unreadable; skip the read_file call
} Try / catch
Match 'Failed to convert' in the message and re-resolve the path against the current project state before retrying once.
Prevention
- In multi-root projects, avoid issuing agent file requests against a root you are about to close
- Re-resolve paths after project layout changes instead of reusing stale ProjectPath values
When it happens
Trigger: read_file on a path whose worktree was closed or removed from the multi-root project between path resolution and the absolute_path call; a path owned by an inconsistent worktree state.
Common situations: A multi-root project where one root folder is closed while an agent request is in flight; project layout changes racing tool calls.
Related errors
- Cannot read file because its path matches the global `file_s
- Cannot read file because its path matches the global `privat
- Cannot read file because its path matches the worktree `file
- Cannot read file because its path matches the worktree `priv
- `cd` directory {cd:?} was not in any root directory in the p
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/14dade1f18e1e86c.
Report an issue: GitHub.