{"record":{"id":"c4117ac30198d3b2","repo":"zed-industries/zed","slug":"git-worktree-directory-resolved-to-resolved-w","errorCode":null,"errorMessage":"git.worktree_directory resolved to {resolved:?}, which is outside the project root and its parent directory. It must resolve to a subdirectory of {repository_anchor_path:?} or a sibling of it.","messagePattern":"git\\.worktree_directory resolved to (.+?), which is outside the project root and its parent directory\\. It must resolve to a subdirectory of (.+?) or a sibling of it\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/project/src/git_store.rs","lineNumber":10546,"sourceCode":"                                && cursor.item().is_some_and(|entry| {\n                                    entry.status == *status\n                                        && entry.diff_stat == current_diff_stat\n                                        && entry.staged_diff_stat == current_staged_diff_stat\n                                        && entry.unstaged_diff_stat == current_unstaged_diff_stat\n                                })\n                            {\n                                continue;\n                            }\n\n                            changed_path_statuses.push(Edit::Insert(StatusEntry {\n                                repo_path: repo_path.clone(),\n                                status: *status,\n                                diff_stat: current_diff_stat,\n                                staged_diff_stat: current_staged_diff_stat,\n                                unstaged_diff_stat: current_unstaged_diff_stat,\n                            }));\n                        }\n                        anyhow::Ok(changed_path_statuses)\n                    })\n                    .await?;\n\n                this.update(&mut cx, |this, cx| {\n                    if !changed_path_statuses.is_empty() {\n                        cx.emit(RepositoryEvent::StatusesChanged);\n                        this.snapshot\n                            .statuses_by_path\n                            .edit(changed_path_statuses, ());\n                        this.snapshot.scan_id += 1;\n                    }\n\n                    if let Some(updates_tx) = updates_tx {\n                        updates_tx\n                            .unbounded_send(DownstreamUpdate::UpdateRepository(\n                                this.snapshot.clone(),\n                            ))\n                            .ok();","sourceCodeStart":10528,"sourceCodeEnd":10564,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/project/src/git_store.rs#L10528-L10564","documentation":"After joining the relative setting onto the repository anchor path and normalizing, the resolved directory must start with either the repository directory or its parent (crates/project/src/git_store.rs:10528). Values whose '..' traversal escapes both - e.g. \"../..\" - are rejected so Zed never manages worktrees outside the project root or its sibling directory.","triggerScenarios":"git.worktree_directory containing enough '..' segments to resolve above the repository's parent directory, for example \"../..\" or \"subdir/../../..\", when a worktree is created.","commonSituations":"Trying to gather all worktrees in a central folder like ~/worktrees; deeply nested repositories where \"../..\" looks harmless.","solutions":["Keep worktrees inside the repository: \"tools/worktrees\" or \".worktrees\"","Keep them directly beside the repository: \"../<repo-name>-worktrees\"","For centralized locations, create a symlink from the allowed sibling directory instead"],"exampleFix":"// settings.json - before\n{ \"git\": { \"worktree_directory\": \"../..\" } }\n\n// settings.json - after\n{ \"git\": { \"worktree_directory\": \"../acme-worktrees\" } }","handlingStrategy":"validation","validationCode":"// Mirror Zed's containment rule before creating worktrees programmatically\nlet joined = repository_anchor_path.join(trimmed_setting);\nlet resolved = normalize_path(joined);\nlet parent = repository_anchor_path.parent().unwrap_or(repository_anchor_path);\nif !resolved.starts_with(parent) {\n    return Err(\"worktree directory escapes the repository root and its parent\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep worktree_directory inside the repo or a named sibling of it","Compute the resolved path and check prefix containment before passing user config onward"],"tags":["git","worktree","settings","path-traversal","configuration"],"backgroundTag":"path-escapes-allowed-root","analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}