zed-industries/zed · error

project path not found for directory mention {abs_path:?}

Error message

project path not found for directory mention {abs_path:?}

What it means

Before attaching a directory mention, Zed maps the absolute directory path to a ProjectPath via project_path_for_absolute_path. This error means no open worktree contains the directory — the path is outside every worktree root of the current project.

Source

Thrown at crates/agent_ui/src/mention_set.rs:1250

            } else if entry.is_file() {
                files.push((
                    entry.path.clone(),
                    worktree
                        .full_path(&entry.path)
                        .to_string_lossy()
                        .to_string(),
                ));
            }
        }

        files
    }

    let Some(project_path) = project
        .read(cx)
        .project_path_for_absolute_path(&abs_path, cx)
    else {
        return Task::ready(Err(anyhow!(
            "project path not found for directory mention {abs_path:?}"
        )));
    };
    let Some(entry) = project.read(cx).entry_for_path(&project_path, cx) else {
        return Task::ready(Err(anyhow!("project entry not found")));
    };
    let directory_path = entry.path.clone();
    let worktree_id = project_path.worktree_id;
    let Some(worktree) = project.read(cx).worktree_for_id(worktree_id, cx) else {
        return Task::ready(Err(anyhow!("worktree not found")));
    };
    let project = project.clone();
    cx.spawn(async move |cx| {
        let file_paths = worktree.read_with(cx, |worktree, _cx| {
            collect_files_in_path(worktree, &directory_path)
        });
        let descendants_future = cx.update(|cx| {
            futures::future::join_all(file_paths.into_iter().map(

View on GitHub (pinned to bc538def45)

Solutions

  1. Re-add or reopen the worktree containing the directory, then mention it again.
  2. Pick the directory from the project panel so the path is guaranteed to be inside a worktree.
  3. If the worktree was re-rooted or moved, reload the project window so paths resolve again.
Defensive patterns

Strategy: validation

Validate before calling

let inside_project = project
    .read(cx)
    .worktrees(cx)
    .any(|worktree| abs_path.starts_with(worktree.read(cx).abs_path()));
if !inside_project {
    // filter the directory out of mention candidates
}

Try / catch

match confirm_task.await {
    Ok(mention) => { /* attach */ }
    Err(err) if err.to_string().starts_with("project path not found") => {
        show_user("This directory is outside the open project")
    }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: Mentioning a directory whose worktree was removed or that belongs to another window; a path built from a stale snapshot after the worktree was re-rooted; a remote-path mismatch where the absolute path does not correspond to the remote worktree root.

Common situations: Multi-root projects where a root was closed while the picker was open; mentioning directories found via search that spans other projects; moving or renaming project roots between sessions.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/66dc2ab49fb4a517. Report an issue: GitHub.