{"record":{"id":"a1b7508c3815c9d7","repo":"zed-industries/zed","slug":"cannot-list-directory-because-its-path-matches-the-a1b750","errorCode":null,"errorMessage":"Cannot list directory because its path matches the user's worktree `file_scan_exclusions` setting: {}","messagePattern":"Cannot list directory because its path matches the user's worktree `file_scan_exclusions` setting: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":293,"sourceCode":"\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                    );\n                }\n\n                let worktree_snapshot = worktree.read(cx).snapshot();\n                let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {\n                    anyhow::bail!(\"Path not found: {}\", input.path);\n                };\n                if !entry.is_dir() {\n                    anyhow::bail!(\"{} is not a directory.\", input.path);","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/list_directory_tool.rs#L275-L311","documentation":"The worktree-scoped variant of the scan-exclusion gate in list_directory. It reads WorktreeSettings::get scoped to the project path (the .zed/settings.json checked into that worktree / project settings) and rejects paths matched by its `file_scan_exclusions`. It runs after both global checks, so this error means the worktree's own settings are what excludes the path.","triggerScenarios":"list_directory on a path that passes global exclusions and private_files but matches a glob in the worktree's local `file_scan_exclusions` (checked via WorktreeSettings::get(Some((&project_path).into()), cx)).","commonSituations":"A repository ships .zed/settings.json excluding vendored or generated directories; teammates see agent errors the global config does not explain.","solutions":["Edit the worktree's .zed/settings.json `file_scan_exclusions` so it no longer matches the path","Ask the agent for a sibling directory that is not excluded","If the checked-in exclusion is intentional, access the directory outside the agent"],"exampleFix":"// before — <repo>/.zed/settings.json\n\"file_scan_exclusions\": [\"vendor/**\"]\n\n// after — exclude only generated vendor output\n\"file_scan_exclusions\": [\"vendor/tmp/**\"]","handlingStrategy":"validation","validationCode":"let excluded = project.read_with(cx, |_, cx| {\n    WorktreeSettings::get(Some((&project_path).into()), cx)\n        .is_path_excluded(&project_path.path)\n});\nif excluded {\n    // worktree-local settings block this path; skip the tool call\n}","typeGuard":null,"tryCatchPattern":"Match `worktree \\`file_scan_exclusions\\`` in the message to distinguish this from the global gate, then point the user at the repo's .zed/settings.json.","preventionTips":["When an agent path is blocked but global settings look clean, check the worktree's own .zed/settings.json","Document checked-in exclusions in the repo README so teammates understand what the agent cannot see"],"tags":["agent","list-directory","file-scan-exclusions","worktree-settings","project-settings"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}