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 `private_paths` setting: {} What it means
The final settings gate in list_directory: the directory matches the worktree-level private paths setting (`private_paths`, enforced through is_path_private on worktree-scoped WorktreeSettings). Like global private_files it is a security boundary, but scoped to the repository, letting a repo declare its own sensitive locations that the agent must never enumerate.
Source
Thrown at crates/agent/src/tools/list_directory_tool.rs:300
}
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);
}
anyhow::Ok(())
}).map_err(|e| e.to_string())?;
if let Some(canonical_target) = &symlink_canonical_target {
let authorize = cx.update(|cx| {View on GitHub (pinned to bc538def45)
Solutions
- Respect the policy — do not expose the private path to the agent
- Narrow the worktree `private_paths` glob in .zed/settings.json if the match is accidental
- Move the content you actually need out of the private-matching path
Example fix
// before — <repo>/.zed/settings.json "private_paths": ["local/**"] // after — only the credentials dir is private "private_paths": ["local/creds/**"]
Defensive patterns
Strategy: validation
Validate before calling
let private = project.read_with(cx, |_, cx| {
WorktreeSettings::get(Some((&project_path).into()), cx)
.is_path_private(&project_path.path)
});
if private {
// repository-declared private path; refuse before calling the tool
} Try / catch
Match `private_paths` in the message and stop; report that the repository's own settings mark the path private.
Prevention
- Scope repo-level private_paths tightly to credential material only
- Treat a private_paths error as a security signal, never as a bug to work around
When it happens
Trigger: list_directory where the global checks pass but the worktree's `private_paths` globs match the requested path.
Common situations: A repository checks in .zed/settings.json marking local credential or key directories private; the agent is asked to explore them.
Related errors
- Cannot list directory because its path matches the user's gl
- Cannot list directory because its path matches the user's wo
- Cannot read file because its path matches the worktree `priv
- 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/3aca45a7e6e3688d.
Report an issue: GitHub.