{"record":{"id":"509fd008e4f7a66f","repo":"zed-industries/zed","slug":"cannot-list-directory-because-its-path-matches-the","errorCode":null,"errorMessage":"Cannot list directory because its path matches the user's global `file_scan_exclusions` setting: {}","messagePattern":"Cannot list directory because its path matches the user's global `file_scan_exclusions` setting: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":278,"sourceCode":"                        ResolvedProjectPath::Safe(path) => (path, None),\n                        ResolvedProjectPath::SymlinkEscape {\n                            project_path,\n                            canonical_target,\n                        } => (project_path, Some(canonical_target)),\n                    })\n                }).map_err(|e| e.to_string())?;\n\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                    );","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/list_directory_tool.rs#L260-L296","documentation":"The agent's list_directory tool refuses paths matched by the user's file_scan_exclusions setting; the global scope is checked first (crates/agent/src/tools/list_directory_tool.rs:278) before worktree scope. The error names the setting and the path — it is a deliberate policy guard keeping the agent out of directories the user excluded from scanning, not a malfunction.","triggerScenarios":"Asking the agent to list a directory whose path matches a glob in the global file_scan_exclusions of settings.json — e.g. **/node_modules, **/target, **/.git, **/dist, **/build.","commonSituations":"Users exclude build and dependency directories for performance; the agent is then asked to explore, search, or fix something inside them and the listing is refused with this message.","solutions":["If the agent should see the directory, remove or narrow the matching glob under file_scan_exclusions in settings.json and retry the request.","List the directory yourself outside the agent and paste or reference the relevant files.","Keep the exclusion but scope the agent's task to specific file paths rather than whole excluded trees.","Narrow the pattern (e.g. root-level node_modules only) so sibling paths stay listable."],"exampleFix":"// settings.json — before\n\"file_scan_exclusions\": [\"**/node_modules\", \"**/dist\", \"**/target\"]\n\n// after (agent needs dist/)\n\"file_scan_exclusions\": [\"**/node_modules\", \"**/target\"]","handlingStrategy":"validation","validationCode":"// before invoking the tool on a path (tool integrations):\nlet settings = WorktreeSettings::get_global(cx);\nif settings.is_path_excluded(&project_path.path) {\n    // tell the user the path is excluded instead of calling the tool\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Review file_scan_exclusions when the agent needs to traverse build outputs.","Prefer narrow exclusion globs over broad ones.","When a listing fails with this message, adjust settings or supply the listing yourself rather than retrying.","Remember worktree-scope exclusions are checked after the global ones with a separate message."],"tags":["agent","settings","exclusions","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"}