zed-industries/zed · error
Cannot list directory because its path matches the user's gl
Error message
Cannot list directory because its path matches the user's global `private_files` setting: {} What it means
Thrown by list_directory when the directory matches a glob in the global `private_files` setting. private_files is a security boundary, not a performance one: it exists to keep secrets (keys, .env files, credentials) out of anything the agent can read or list. The tool enforces it synchronously before touching the filesystem.
Source
Thrown at crates/agent/src/tools/list_directory_tool.rs:285
// Check settings exclusions synchronously
project.read_with(cx, |project, cx| {
let worktree = project
.worktree_for_id(project_path.worktree_id, cx)
.with_context(|| {
format!("{} is not in a known worktree", input.path)
})?;
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
);View on GitHub (pinned to bc538def45)
Solutions
- Do not list or read the protected directory via the agent — private_files intentionally hides secrets from agent context
- If the glob over-matches non-secret content, narrow `private_files` in global settings.json and retry
- Move the non-secret files you need out of the private-matching path
Example fix
// before — global settings.json over-blocks a docs dir "private_files": ["**/secrets/**", "**/keys/**"] // after — only actual credential material is private "private_files": ["**/secrets/**"]
Defensive patterns
Strategy: validation
Validate before calling
let private = project.read_with(cx, |_, cx| {
WorktreeSettings::get_global(cx).is_path_private(&project_path.path)
});
if private {
// refuse early; never forward a private path to an agent tool
} Try / catch
On error, match `private_files` in the message and stop — surface to the user that the path is private by policy. Never retry or attempt to bypass.
Prevention
- Keep secrets under paths covered by private_files so the agent can never list or read them
- Never loosen private_files to make an agent tool call succeed; move the non-secret files instead
When it happens
Trigger: A list_directory call whose path matches a global `private_files` glob (commonly `.env*`, `**/*.pem`, `**/id_rsa*`, `**/.ssh/**`). Checked after the global file_scan_exclusions gate.
Common situations: The agent is pointed at a secrets folder or dotfile directory that the user or defaults intentionally protect; the block is by design, not a bug.
Related errors
- Cannot read file because its path matches the global `privat
- 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
- Invalid model ID {}
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/6605e61b1f448866.
Report an issue: GitHub.