{"record":{"id":"4957a114312b4367","repo":"zed-industries/zed","slug":"cannot-read-file-because-its-path-matches-the-work","errorCode":null,"errorMessage":"Cannot read file because its path matches the worktree `file_scan_exclusions` setting: {}","messagePattern":"Cannot read file because its path matches the worktree `file_scan_exclusions` setting: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/read_file_tool.rs","lineNumber":327,"sourceCode":"                }\n\n                if global_settings.is_path_private(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot read file because its path matches the 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 read file because its path matches the 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 read file because its path matches the worktree `private_files` setting: {}\",\n                        input.path\n                    );\n                }\n\n                anyhow::Ok(())\n            }).map_err(tool_content_err)?;\n\n            if fs.is_dir(&abs_path).await {\n                return Err(tool_content_err(format!(\n                    \"{} is a directory, not a file. Use the list_directory tool to explore directory contents.\",\n                    input.path\n                )));\n            }\n\n            if let Some(canonical_target) = &symlink_canonical_target {\n                let authorize = cx.update(|cx| {\n                    authorize_symlink_access(","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/read_file_tool.rs#L309-L345","documentation":"The third gate in the `read_file` tool: after global checks pass, the worktree-level settings are fetched with `WorktreeSettings::get(Some((&project_path).into()), cx)` and the path is tested against `is_path_excluded`. A match against the project's own `file_scan_exclusions` produces this error.","triggerScenarios":"The agent reads a path matched by `file_scan_exclusions` in the project's `.zed/settings.json` (checked into the repo, affecting everyone who opens it).","commonSituations":"A repo commits `.zed/settings.json` excluding `dist/`, `coverage/`, or generated protobuf code; contributors' agents then cannot read those paths. Also hit when the project panel shows the file but the scan excluded it from agent access.","solutions":["Edit the project `.zed/settings.json` and narrow the `file_scan_exclusions` pattern so the needed file is not matched.","Ask the repo owner whether the exclusion is load-bearing before changing committed settings.","Read the file outside the agent (editor/chat paste) if the exclusion must remain.","Verify no global-level pattern also matches, since global gates run first."],"exampleFix":"// .zed/settings.json (project)\n// before\n{\n  \"file_scan_exclusions\": [\"generated\"]\n}\n// after — keep bulky artifacts excluded but let summary files through\n{\n  \"file_scan_exclusions\": [\"generated/**/*\", \"!generated/README.md\"]\n}","handlingStrategy":"validation","validationCode":"let worktree = WorktreeSettings::get(Some((&project_path).into()), cx);\nif worktree.is_path_excluded(&project_path.path) {\n    // worktree-level exclusion: skip the read or request a settings change\n}","typeGuard":null,"tryCatchPattern":"match read_file(path).await {\n    Err(e) if e.to_string().contains(\"worktree `file_scan_exclusions`\") => {\n        // project-level policy — surface to the user, don't retry\n    }\n    rest => rest,\n}","preventionTips":["Review committed `.zed/settings.json` exclusions when onboarding a repo.","Prefer excluding generated subtrees over excluding whole top-level directories.","Use negation/narrow patterns to keep specific files readable when needed."],"tags":["rust","zed","agent","read-file","settings","file-scan-exclusions","access-denied"],"backgroundTag":"file-access-denied-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"}