{"record":{"id":"f4b34f6092a93204","repo":"Hmbown/CodeWhale","slug":"worktree-path-already-exists","errorCode":null,"errorMessage":"worktree path already exists: {}","messagePattern":"worktree path already exists: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/ui/session_state.rs","lineNumber":580,"sourceCode":"        .args([\"rev-parse\", \"--show-toplevel\"])\n        .output()\n        .context(\"inspect Git repository for new worktree\")?;\n    if !output.status.success() {\n        anyhow::bail!(\"new worktree requires a Git repository\");\n    }\n    let repo_root = PathBuf::from(String::from_utf8(output.stdout)?.trim());\n    let repo_name = repo_root\n        .file_name()\n        .and_then(|name| name.to_str())\n        .filter(|name| !name.is_empty())\n        .unwrap_or(\"workspace\");\n    let slug = launch_worktree_slug(requested);\n    let parent = repo_root.parent().unwrap_or(repo_root.as_path());\n    let path = parent\n        .join(\".codewhale-worktrees\")\n        .join(format!(\"{repo_name}-{slug}\"));\n    if path.exists() {\n        anyhow::bail!(\"worktree path already exists: {}\", path.display());\n    }\n    Ok(codewhale_lane::WorktreeProvision {\n        repo_root,\n        branch: format!(\"codex/{slug}\"),\n        path,\n        base_ref: Some(\"HEAD\".to_string()),\n    })\n}\n\npub(crate) async fn provision_launch_worktree(\n    workspace: PathBuf,\n    requested: String,\n) -> Result<PathBuf> {\n    let spec = launch_worktree_spec(&workspace, &requested)?;\n    let provisioned =\n        tokio::task::spawn_blocking(move || codewhale_lane::provision_worktree(&spec))\n            .await\n            .context(\"new worktree task failed\")??;","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/ui/session_state.rs#L562-L598","documentation":"Raised in launch_worktree_spec when the computed path for the new worktree (repo parent + slug) already exists on disk. Git worktree provisioning requires a fresh directory; an existing path is refused rather than overwritten to avoid destroying whatever occupies it.","triggerScenarios":"Thrown at crates/tui/src/tui/ui/session_state.rs:580 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a different worktree name/slug that does not collide","Remove or relocate the existing directory if it is stale","Reuse the existing worktree if it was created for this purpose previously"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}