zed-industries/zed · error
Path not found: {}
Error message
Path not found: {} What it means
The list-directory tool resolved the input path to a known worktree, but the worktree snapshot has no entry at that path — `entry_for_path` returned None. As far as the indexed snapshot is concerned the path does not exist: never created, deleted, not yet rescanned, or excluded from the snapshot.
Source
Thrown at crates/agent/src/tools/list_directory_tool.rs:127
fn build_directory_output(
project: &Entity<Project>,
project_path: &ProjectPath,
input_path: &str,
cx: &App,
) -> Result<String> {
let worktree = project
.read(cx)
.worktree_for_id(project_path.worktree_id, cx)
.with_context(|| format!("{input_path} is not in a known worktree"))?;
let global_settings = WorktreeSettings::get_global(cx);
let worktree_settings = WorktreeSettings::get(Some(project_path.into()), cx);
let worktree_snapshot = worktree.read(cx).snapshot();
let worktree_root_name = worktree.read(cx).root_name();
let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {
return Err(anyhow!("Path not found: {}", input_path));
};
if !entry.is_dir() {
return Err(anyhow!("{input_path} is not a directory."));
}
let mut folders = Vec::new();
let mut files = Vec::new();
for entry in worktree_snapshot.child_entries(&project_path.path) {
// Skip private and excluded files and directories
if global_settings.is_path_private(&entry.path)
|| global_settings.is_path_excluded(&entry.path)
{
continue;
}
let project_path: ProjectPath = (worktree_snapshot.id(), entry.path.clone()).into();View on GitHub (pinned to bc538def45)
Solutions
- Verify the path exists on disk and inside the worktree root; fix typos and casing.
- Create the directory first (mkdir) before listing it.
- Trigger or wait for a worktree rescan if the path was just created externally.
- Check gitignore/private/exclusion settings if the path is intentionally hidden from the snapshot.
Example fix
# before
list_directory("src/new_module") # Path not found
# after
run_terminal("mkdir -p src/new_module")
list_directory("src/new_module") Defensive patterns
Strategy: validation
Validate before calling
let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {
anyhow::bail!("{input_path} not present in the worktree snapshot");
}; Type guard
fn path_exists_in_worktree(
snapshot: &WorktreeSnapshot,
project_path: &ProjectPath,
) -> bool {
snapshot.entry_for_path(&project_path.path).is_some()
} Prevention
- Create directories before listing them.
- Refresh the worktree snapshot after external filesystem changes.
- Check gitignore/private/exclusion settings when expected paths go missing.
When it happens
Trigger: Listing a path that was deleted, has not been created/saved yet, lies outside the snapshot's indexed set (ignored/excluded entries), contains typos or case mismatches, or was created externally before a rescan.
Common situations: The model asking to list directories it only plans to create; gitignored paths absent from the snapshot; externally created dirs not yet picked up; case-sensitive mismatches on case-insensitive filesystems.
Related errors
- {input_path} is not a directory.
- cannot capture writable sandbox path `{}`
- Invalid glob: {err}
- Path {} is not in the project
- Unexpected response structure: ${JSON.stringify(data)}
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/b74a3b1fb5905255.
Report an issue: GitHub.