zed-industries/zed · error

Failed to convert to absolute path

Error message

Failed to convert {} to absolute path

What it means

Raised in the read_file tool's run handler when the path returned by resolve_project_path cannot be converted from a project-relative Path into an absolute filesystem path. The input path resolved against the worktree but the resulting combination could not be produced as an absolute path, typically because the underlying worktree root is missing or the joined path is malformed.

Solutions

  1. Verify the input path is a valid relative path inside an open worktree
  2. Ensure the project still contains the worktree the path belongs to before invoking the tool
  3. Retry with an unambiguous relative path from the worktree root
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/agent/src/tools/read_file_tool.rs:298 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/14dade1f18e1e86c. Report an issue: GitHub.

Appendix: 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 f4178619ac)