zed-industries/zed · error
Cannot list directory because its path matches the user's wo
Error message
Cannot list directory because its path matches the user's worktree `file_scan_exclusions` setting: {} What it means
The worktree-scoped variant of the scan-exclusion gate in list_directory. It reads WorktreeSettings::get scoped to the project path (the .zed/settings.json checked into that worktree / project settings) and rejects paths matched by its `file_scan_exclusions`. It runs after both global checks, so this error means the worktree's own settings are what excludes the path.
Source
Thrown at crates/agent/src/tools/list_directory_tool.rs:293
let global_settings = WorktreeSettings::get_global(cx);
if global_settings.is_path_excluded(&project_path.path) {
anyhow::bail!(
"Cannot list directory because its path matches the user's global `file_scan_exclusions` setting: {}",
input.path
);
}
if global_settings.is_path_private(&project_path.path) {
anyhow::bail!(
"Cannot list directory because its path matches the user's global `private_files` setting: {}",
input.path
);
}
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);View on GitHub (pinned to bc538def45)
Solutions
- Edit the worktree's .zed/settings.json `file_scan_exclusions` so it no longer matches the path
- Ask the agent for a sibling directory that is not excluded
- If the checked-in exclusion is intentional, access the directory outside the agent
Example fix
// before — <repo>/.zed/settings.json "file_scan_exclusions": ["vendor/**"] // after — exclude only generated vendor output "file_scan_exclusions": ["vendor/tmp/**"]
Defensive patterns
Strategy: validation
Validate before calling
let excluded = project.read_with(cx, |_, cx| {
WorktreeSettings::get(Some((&project_path).into()), cx)
.is_path_excluded(&project_path.path)
});
if excluded {
// worktree-local settings block this path; skip the tool call
} Try / catch
Match `worktree \`file_scan_exclusions\`` in the message to distinguish this from the global gate, then point the user at the repo's .zed/settings.json.
Prevention
- When an agent path is blocked but global settings look clean, check the worktree's own .zed/settings.json
- Document checked-in exclusions in the repo README so teammates understand what the agent cannot see
When it happens
Trigger: list_directory on a path that passes global exclusions and private_files but matches a glob in the worktree's local `file_scan_exclusions` (checked via WorktreeSettings::get(Some((&project_path).into()), cx)).
Common situations: A repository ships .zed/settings.json excluding vendored or generated directories; teammates see agent errors the global config does not explain.
Related errors
- Cannot read file because its path matches the worktree `file
- Cannot list directory because its path matches the user's gl
- Cannot list directory because its path matches the user's wo
- Cannot list directory because its path matches the user's gl
- {} is not a directory.
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/a1b7508c3815c9d7.
Report an issue: GitHub.