{"record":{"id":"ecba070531e1f65a","repo":"Hmbown/CodeWhale","slug":"repo-root-does-not-exist","errorCode":null,"errorMessage":"repo root does not exist: {}","messagePattern":"repo root does not exist: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/lane/src/worktree.rs","lineNumber":36,"sourceCode":"    /// Directory for the new worktree (created by `git worktree add`).\n    pub path: PathBuf,\n    /// Base ref to branch from (default `HEAD`).\n    pub base_ref: Option<String>,\n}\n\n#[derive(Debug, Clone)]\npub struct ProvisionedWorktree {\n    pub path: PathBuf,\n    pub branch: String,\n}\n\n/// Create a git worktree + branch for a lane.\npub fn provision_worktree(spec: &WorktreeProvision) -> Result<ProvisionedWorktree> {\n    if spec.branch.trim().is_empty() {\n        bail!(\"worktree branch must not be empty\");\n    }\n    if !spec.repo_root.exists() {\n        bail!(\"repo root does not exist: {}\", spec.repo_root.display());\n    }\n    if let Some(parent) = spec.path.parent() {\n        fs::create_dir_all(parent)\n            .with_context(|| format!(\"create worktree parent {}\", parent.display()))?;\n    }\n    let base = spec.base_ref.as_deref().unwrap_or(\"HEAD\");\n    // Capture git output instead of inheriting the caller's terminal. Runtime\n    // callers include the raw-mode TUI launch screen, where even one inherited\n    // progress/error line corrupts the alternate-screen buffer.\n    let output = Command::new(\"git\")\n        .current_dir(&spec.repo_root)\n        .args([\n            \"worktree\",\n            \"add\",\n            \"-b\",\n            &spec.branch,\n            &spec.path.to_string_lossy(),\n            base,","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/lane/src/worktree.rs#L18-L54","documentation":"Thrown by provision_worktree() in codewhale-lane before any git command runs: the WorktreeProvision.repo_root path passed by the caller does not exist on disk. The check guards the later `git -C <repo_root> worktree add`, which would otherwise fail with a less actionable error. It is a pure caller-input validation error, not a git state problem.","triggerScenarios":"Calling provision_worktree() with a repo_root that is a typo'd path, a relative path resolved against an unexpected current working directory, a repo directory that was moved/deleted after discovery, or a repo that was never cloned. Also triggered when repo_root is derived from stale configuration or an env var that is unset (yielding an empty or wrong path).","commonSituations":"CI sandboxes where the checkout lives at a different absolute path than locally; configs persisting an old workspace location; relative paths like \"../repo\" interpreted from the TUI's cwd instead of the launcher's; lane specs replayed after the user reorganized their workspace.","solutions":["Verify the path exists and is a git repository before calling: path.is_dir() && path.join(\".git\").exists()","Derive repo_root from git itself (`git rev-parse --show-toplevel`) instead of trusting configuration","Canonicalize the path (std::fs::canonicalize) so later comparisons and git invocations use one absolute form","If the repo legitimately moved, update the lane/worktree spec source (config or state store) to the new location"],"exampleFix":"// before\nlet spec = WorktreeProvision {\n    repo_root: PathBuf::from(&config.repo_path),\n    branch: branch_name.clone(),\n    path: worktree_dir.clone(),\n    base_ref: None,\n};\nlet wt = provision_worktree(&spec)?;\n\n// after\nlet repo_root = std::fs::canonicalize(&config.repo_path)\n    .with_context(|| format!(\"locate repo at {}\", config.repo_path))?;\nif !repo_root.join(\".git\").exists() {\n    bail!(\"{} is not a git repository\", repo_root.display());\n}\nlet spec = WorktreeProvision {\n    repo_root,\n    branch: branch_name.clone(),\n    path: worktree_dir.clone(),\n    base_ref: None,\n};\nlet wt = provision_worktree(&spec)?;","handlingStrategy":"validation","validationCode":"fn usable_repo_root(p: &Path) -> bool {\n    p.is_dir() && p.join(\".git\").exists()\n}\n\n// before provisioning:\nif !usable_repo_root(&spec.repo_root) {\n    bail!(\"repo root {} missing or not a git repo\", spec.repo_root.display());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive repo_root via `git rev-parse --show-toplevel` instead of storing absolute paths in config","Canonicalize the path once at discovery and pass the same absolute PathBuf everywhere","Fail fast in lane-spec loading when the referenced repo does not resolve"],"tags":["git","worktree","filesystem","path-validation","lane"],"backgroundTag":"file-not-found","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}