{"record":{"id":"cb7bb01bb68b140c","repo":"zed-industries/zed","slug":"cannot-read-file-because-its-path-matches-the-glob","errorCode":null,"errorMessage":"Cannot read file because its path matches the global `file_scan_exclusions` setting: {}","messagePattern":"Cannot read file because its path matches the global `file_scan_exclusions` setting: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/read_file_tool.rs","lineNumber":305,"sourceCode":"                            project_path,\n                            canonical_target,\n                        } => (project_path, Some(canonical_target)),\n                    })\n                }).map_err(tool_content_err)?;\n\n            let abs_path = project\n                .read_with(cx, |project, cx| {\n                    project.absolute_path(&project_path, cx)\n                })\n                .ok_or_else(|| {\n                    anyhow!(\"Failed to convert {} to absolute path\", input.path)\n                }).map_err(tool_content_err)?;\n\n            // Check settings exclusions synchronously\n            project.read_with(cx, |_project, cx| {\n                let global_settings = WorktreeSettings::get_global(cx);\n                if global_settings.is_path_excluded(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot read file because its path matches the 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 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                    );","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/read_file_tool.rs#L287-L323","documentation":"The agent `read_file` tool refuses to read a file whose path matches the global `file_scan_exclusions` setting (`WorktreeSettings::get_global(cx).is_path_excluded(...)`). Excluded paths are kept out of agent context by design, so reads are blocked with this message naming the offending path. This is the first of four exclusion/privacy checks run synchronously before the file is opened.","triggerScenarios":"Invoking the agent's `read_file` tool on a path matched by `file_scan_exclusions` in the user-level global settings (`~/.config/zed/settings.json` on Linux, `~/Library/Application Support/Zed/settings.json` on macOS).","commonSituations":"Global exclusions for `node_modules`, `target`, `.git`, lockfiles, or large generated files are set once and forgotten; later the agent is asked to read one of those files and fails. Also triggered by over-broad globs that accidentally match source files.","solutions":["Remove or narrow the matching pattern in the global Zed settings `file_scan_exclusions` array.","Allow the specific path via a worktree-level setting if your Zed version supports overrides, or move the file out of the matched subtree.","Paste the file contents into the chat directly if a one-off read is needed.","Confirm which pattern matched — test the glob against the path before editing settings."],"exampleFix":"// ~/.config/zed/settings.json (global)\n// before\n{\n  \"file_scan_exclusions\": [\"dist\"]\n}\n// after — only exclude build artifacts, keep sources readable\n{\n  \"file_scan_exclusions\": [\"dist/*.min.js\"]\n}","handlingStrategy":"validation","validationCode":"if WorktreeSettings::get_global(cx).is_path_excluded(&project_path.path) {\n    // globally scan-excluded: skip the read_file call, or ask the user to adjust settings\n}","typeGuard":null,"tryCatchPattern":"match read_file(path).await {\n    Err(e) if e.to_string().contains(\"global `file_scan_exclusions`\") => {\n        // deterministic refusal — surface reason, don't retry\n    }\n    rest => rest,\n}","preventionTips":["Keep global `file_scan_exclusions` minimal; put project-specific excludes in the project's `.zed/settings.json`.","Pre-check candidate paths with `is_path_excluded` when generating read plans in agent code.","Document which globs are global so teammates can trace refusals quickly."],"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"}