{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","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/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/list_directory_tool.rs#L260-L296","documentation":"Thrown by the agent's list_directory tool when the requested directory matches a glob in the user's global `file_scan_exclusions` setting. The check reads WorktreeSettings::get_global on the foreground thread before any filesystem access, so scan-excluded directories are deliberately invisible to the agent. This is the first of four settings gates (global exclusions, global private_files, worktree exclusions, worktree private_paths).","triggerScenarios":"A list_directory tool call whose project path matches any glob in the global `file_scan_exclusions` list (defaults and common user config cover patterns like `**/node_modules`, `**/target`, `**/.git`). Runs before the private_files and worktree-level checks.","commonSituations":"Asking the agent to explore node_modules, build output, or .git directories that default or user globs cover; a user adds a broad glob like `**/build/**` to settings.json and later forgets it blocks the agent too.","solutions":["Narrow or remove the matching glob in the global `file_scan_exclusions` setting (Zed settings.json), then retry the request","Point the agent at a more specific subdirectory the globs do not match","If the exclusion is intentional for performance, browse the directory outside the agent (editor file tree or terminal)"],"exampleFix":"// before — global settings.json glob blocks the agent\n\"file_scan_exclusions\": [\"**/dist/**\", \"**/examples/**\"]\n\n// after — heavy build output stays excluded, examples visible to the agent\n\"file_scan_exclusions\": [\"**/dist/**\"]","handlingStrategy":"validation","validationCode":"let excluded = project.read_with(cx, |_, cx| {\n    WorktreeSettings::get_global(cx).is_path_excluded(&project_path.path)\n});\nif excluded {\n    // skip the list_directory call; report that the path is scan-excluded\n}","typeGuard":null,"tryCatchPattern":"Match `file_scan_exclusions` in the tool error string and treat it as terminal for that path — report the offending path back to the model instead of retrying with the same input.","preventionTips":["Keep file_scan_exclusions globs narrow; remember they hide paths from the agent as well as from indexing","Before asking the agent to explore a directory, check it appears in Zed's file tree — excluded directories are hidden there too"],"tags":["agent","list-directory","file-scan-exclusions","settings","zed"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}