{"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":"exception","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/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/read_file_tool.rs#L287-L323","documentation":"The read_file tool refuses files matching the global `file_scan_exclusions` setting, checking WorktreeSettings::get_global before any filesystem access. This keeps scan-excluded files (lockfiles, build artifacts, vendored code) out of agent context, mirroring the list_directory gate for file reads.","triggerScenarios":"read_file on a path matched by a global `file_scan_exclusions` glob — commonly pnpm-lock.yaml, Cargo.lock output dirs, node_modules files, or vendored code covered by defaults or user globs.","commonSituations":"The agent is asked to read a lockfile or a file under node_modules/target that default or user exclusions cover; user-added globs block files the agent needs.","solutions":["Narrow or remove the matching glob in the global `file_scan_exclusions` setting and retry","Paste the relevant snippet into the chat instead of having the agent read the excluded file","Read the file outside the agent if the exclusion is intentional"],"exampleFix":"// before — global settings.json\n\"file_scan_exclusions\": [\"**/pnpm-lock.yaml\"]\n\n// after — rely on defaults; the agent can read the lockfile\n\"file_scan_exclusions\": []","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 read_file; the global scan exclusions hide this file from the agent\n}","typeGuard":null,"tryCatchPattern":"Match the read-file `file_scan_exclusions` message, name the offending glob, and either narrow the setting or supply the content out-of-band.","preventionTips":["Review file_scan_exclusions before onboarding a codebase to agent workflows","For files the agent must read often (lockfiles, configs), make sure no glob accidentally matches them"],"tags":["agent","read-file","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"}