{"record":{"id":"b74a3b1fb5905255","repo":"zed-industries/zed","slug":"path-not-found","errorCode":null,"errorMessage":"Path not found: {}","messagePattern":"Path not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":127,"sourceCode":"\n    fn build_directory_output(\n        project: &Entity<Project>,\n        project_path: &ProjectPath,\n        input_path: &str,\n        cx: &App,\n    ) -> Result<String> {\n        let worktree = project\n            .read(cx)\n            .worktree_for_id(project_path.worktree_id, cx)\n            .with_context(|| format!(\"{input_path} is not in a known worktree\"))?;\n\n        let global_settings = WorktreeSettings::get_global(cx);\n        let worktree_settings = WorktreeSettings::get(Some(project_path.into()), cx);\n        let worktree_snapshot = worktree.read(cx).snapshot();\n        let worktree_root_name = worktree.read(cx).root_name();\n\n        let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {\n            return Err(anyhow!(\"Path not found: {}\", input_path));\n        };\n\n        if !entry.is_dir() {\n            return Err(anyhow!(\"{input_path} is not a directory.\"));\n        }\n\n        let mut folders = Vec::new();\n        let mut files = Vec::new();\n\n        for entry in worktree_snapshot.child_entries(&project_path.path) {\n            // Skip private and excluded files and directories\n            if global_settings.is_path_private(&entry.path)\n                || global_settings.is_path_excluded(&entry.path)\n            {\n                continue;\n            }\n\n            let project_path: ProjectPath = (worktree_snapshot.id(), entry.path.clone()).into();","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/list_directory_tool.rs#L109-L145","documentation":"The list-directory tool resolved the input path to a known worktree, but the worktree snapshot has no entry at that path — `entry_for_path` returned None. As far as the indexed snapshot is concerned the path does not exist: never created, deleted, not yet rescanned, or excluded from the snapshot.","triggerScenarios":"Listing a path that was deleted, has not been created/saved yet, lies outside the snapshot's indexed set (ignored/excluded entries), contains typos or case mismatches, or was created externally before a rescan.","commonSituations":"The model asking to list directories it only plans to create; gitignored paths absent from the snapshot; externally created dirs not yet picked up; case-sensitive mismatches on case-insensitive filesystems.","solutions":["Verify the path exists on disk and inside the worktree root; fix typos and casing.","Create the directory first (mkdir) before listing it.","Trigger or wait for a worktree rescan if the path was just created externally.","Check gitignore/private/exclusion settings if the path is intentionally hidden from the snapshot."],"exampleFix":"# before\nlist_directory(\"src/new_module\")   # Path not found\n\n# after\nrun_terminal(\"mkdir -p src/new_module\")\nlist_directory(\"src/new_module\")","handlingStrategy":"validation","validationCode":"let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {\n    anyhow::bail!(\"{input_path} not present in the worktree snapshot\");\n};","typeGuard":"fn path_exists_in_worktree(\n    snapshot: &WorktreeSnapshot,\n    project_path: &ProjectPath,\n) -> bool {\n    snapshot.entry_for_path(&project_path.path).is_some()\n}","tryCatchPattern":null,"preventionTips":["Create directories before listing them.","Refresh the worktree snapshot after external filesystem changes.","Check gitignore/private/exclusion settings when expected paths go missing."],"tags":["filesystem","worktree","tooling","path"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}