{"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":"validation","errorClass":null,"httpStatus":null,"severity":"warning","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/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/list_directory_tool.rs#L267-L303","documentation":"The second guard in list_directory: after the global file_scan_exclusions check, paths matched by the global private_files setting are refused (crates/agent/src/tools/list_directory_tool.rs:285). private_files marks directories whose contents must never reach agent context (secrets, credentials). The bail is by design and names the setting and path.","triggerScenarios":"Asking the agent to list a directory matched by a private_files glob in settings.json — typical patterns include **/.ssh, **/.gnupg, **/.aws, or user-added secrets directories.","commonSituations":"Agent asked to inspect configuration that lives inside a protected directory; overly broad user patterns that accidentally cover working directories.","solutions":["Do not bypass it: private_files exists to keep secrets out of agent context.","If the directory is not actually sensitive, remove or narrow the glob under private_files in settings.json.","Copy the specific non-secret files you need out of the protected directory and point the agent at the copies.","Audit broad patterns for accidental matches on ordinary working paths."],"exampleFix":"// settings.json — before\n\"private_files\": [\"**/.config/**\"]\n\n// after (narrowed to actual secrets)\n\"private_files\": [\"**/.ssh/**\", \"**/.aws/**\"]","handlingStrategy":"validation","validationCode":"// before invoking the tool on a path (tool integrations):\nlet settings = WorktreeSettings::get_global(cx);\nif settings.is_path_private(&project_path.path) {\n    // path is protected by private_files; do not attempt to list it\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never try to bypass private_files — it keeps secrets out of agent context.","Keep private_files patterns narrowly scoped to actual secret directories.","Copy specific non-secret files out of protected directories when the agent needs them.","Audit broad patterns (e.g. **/.config/**) for accidental matches on working paths."],"tags":["agent","settings","private-files","access-denied","zed"],"backgroundTag":"path-excluded-by-settings","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}