{"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":null,"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/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/lane/src/worktree.rs#L18-L54","documentation":"Input validation in `provision_worktree` (crates/lane/src/worktree.rs): `spec.repo_root` does not exist on disk, checked via `Path::exists()` before creating the worktree. Git cannot add a worktree relative to a nonexistent repository root, so the library fails with the path in the message.","triggerScenarios":"Calling `provision_worktree` with `repo_root` pointing to a missing directory — wrong relative path, deleted/temp repo, or a root created after provisioning was invoked.","commonSituations":"Running the tool from a copied/sandboxed directory where the repo root path changed; typos in a configured repo root; calling provisioning before cloning the repository; tests using a temp dir that was already cleaned up.","solutions":["Pass the absolute, existing path of the git repository as `repo_root`.","Clone or create the repository before provisioning the worktree.","Canonicalize the configured repo root once at startup and reuse that value."],"exampleFix":"// before\nrepo_root: PathBuf::from(\"../my-repo\")\n// after\nlet repo_root = std::fs::canonicalize(\"/work/my-repo\")?;\nWorktreeProvision { repo_root, .. }","handlingStrategy":"validation","validationCode":"let repo_root = std::fs::canonicalize(&spec.repo_root)?; // errors early if missing\nanyhow::ensure!(repo_root.join(\".git\").exists(), \"not a repo: {}\", repo_root.display());","typeGuard":"fn repo_ready(p: &Path) -> bool { p.exists() && p.join(\".git\").exists() }","tryCatchPattern":null,"preventionTips":["Canonicalize and store the repo root once at startup.","Clone/checkout the repository before provisioning worktrees.","Avoid relative repo_root paths that depend on the process CWD."],"tags":["worktree","path","git"],"backgroundTag":"directory-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}