{"record":{"id":"6605e61b1f448866","repo":"zed-industries/zed","slug":"cannot-list-directory-because-its-path-matches-the-6605e6","errorCode":null,"errorMessage":"Cannot list directory because its path matches the user's global `private_files` setting: {}","messagePattern":"Cannot list directory because its path matches the user's global `private_files` setting: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":285,"sourceCode":"\n            // Check settings exclusions synchronously\n            project.read_with(cx, |project, cx| {\n                let worktree = project\n                    .worktree_for_id(project_path.worktree_id, cx)\n                    .with_context(|| {\n                        format!(\"{} is not in a known worktree\", input.path)\n                    })?;\n\n                let global_settings = WorktreeSettings::get_global(cx);\n                if global_settings.is_path_excluded(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot list directory because its path matches the user's global `file_scan_exclusions` setting: {}\",\n                        input.path\n                    );\n                }\n\n                if global_settings.is_path_private(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot list directory because its path matches the user's global `private_files` setting: {}\",\n                        input.path\n                    );\n                }\n\n                let worktree_settings = WorktreeSettings::get(Some((&project_path).into()), cx);\n                if worktree_settings.is_path_excluded(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot list directory because its path matches the user's worktree `file_scan_exclusions` setting: {}\",\n                        input.path\n                    );\n                }\n\n                if worktree_settings.is_path_private(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot list directory because its path matches the user's worktree `private_paths` setting: {}\",\n                        input.path\n                    );","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/list_directory_tool.rs#L267-L303","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before — global settings.json over-blocks a docs dir\n\"private_files\": [\"**/secrets/**\", \"**/keys/**\"]\n\n// after — only actual credential material is private\n\"private_files\": [\"**/secrets/**\"]","handlingStrategy":"validation","validationCode":"let private = project.read_with(cx, |_, cx| {\n    WorktreeSettings::get_global(cx).is_path_private(&project_path.path)\n});\nif private {\n    // refuse early; never forward a private path to an agent tool\n}","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["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"],"tags":["agent","list-directory","private-files","settings","security"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}