zed-industries/zed · error
Path not found
Error message
Path not found: {} What it means
The `list_directory` tool resolves the input path against a project worktree and looks it up in that worktree's snapshot via `entry_for_path`. When the snapshot contains no entry for the path, the tool bails with `Path not found: {input.path}`. The snapshot reflects what the worktree's fs scan knows, so brand-new or unscanned directories can also miss.
Solutions
- List the parent directory first (`list_directory` on `.` or the parent) to see the actual entry names.
- Verify the path is inside one of the project's open worktree roots and spelled exactly (case-sensitive on Linux).
- For a freshly created directory, wait for the fs scan or trigger it by focusing the project panel, then retry.
- Check the file actually exists on disk (`ls` the path) to rule out a stale snapshot.
Defensive patterns
Strategy: validation
Validate before calling
// Check the snapshot before invoking the tool:
let snapshot = worktree.read(cx).snapshot();
if snapshot.entry_for_path(&project_path.path).is_none() {
// path unknown to the worktree (deleted, typo, other worktree) — don't call
} Try / catch
match list_directory(path).await {
Err(e) if e.to_string().starts_with("Path not found") => {
// list the parent directory to discover valid entries
}
rest => rest,
} Prevention
- Resolve agent-visible paths from `worktree_snapshot.entry_for_path`, not from raw strings.
- List parent directories first to validate names before diving deeper.
- Re-check the snapshot after create/rename operations instead of assuming the entry exists.
When it happens
Trigger: Calling `list_directory` on a deleted/renamed directory, a path with a typo, a path that lives in a different worktree than the one it was resolved to, or a directory created so recently the worktree scan has not recorded it yet.
Common situations: The agent guesses at a directory name that does not exist; the user renamed the folder mid-session; the path is outside every open worktree root; or a just-created build directory is not yet in the snapshot.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Cannot list directory because its path matches the user's…
- Cannot list directory because its path matches the user's…
- is not a directory.
- auto_compact threshold of 0 is not valid
- Cannot read file because its path matches the global…
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/b74a3b1fb5905255.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent/src/tools/list_directory_tool.rs:308
let worktree_settings = WorktreeSettings::get(Some((&project_path).into()), cx);
if worktree_settings.is_path_excluded(&project_path.path) {
anyhow::bail!(
"Cannot list directory because its path matches the user's worktree `file_scan_exclusions` setting: {}",
input.path
);
}
if worktree_settings.is_path_private(&project_path.path) {
anyhow::bail!(
"Cannot list directory because its path matches the user's worktree `private_paths` setting: {}",
input.path
);
}
let worktree_snapshot = worktree.read(cx).snapshot();
let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {
anyhow::bail!("Path not found: {}", input.path);
};
if !entry.is_dir() {
anyhow::bail!("{} is not a directory.", input.path);
}
anyhow::Ok(())
}).map_err(|e| e.to_string())?;
if let Some(canonical_target) = &symlink_canonical_target {
let authorize = cx.update(|cx| {
authorize_symlink_access(
Self::NAME,
&input.path,
canonical_target,
&event_stream,
cx,
)
});View on GitHub (pinned to f4178619ac)