Hmbown/CodeWhale · error
worktree path already exists: {}
Error message
worktree path already exists: {} What it means
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.
Source
Thrown at crates/tui/src/tui/ui/session_state.rs:580
.args(["rev-parse", "--show-toplevel"])
.output()
.context("inspect Git repository for new worktree")?;
if !output.status.success() {
anyhow::bail!("new worktree requires a Git repository");
}
let repo_root = PathBuf::from(String::from_utf8(output.stdout)?.trim());
let repo_name = repo_root
.file_name()
.and_then(|name| name.to_str())
.filter(|name| !name.is_empty())
.unwrap_or("workspace");
let slug = launch_worktree_slug(requested);
let parent = repo_root.parent().unwrap_or(repo_root.as_path());
let path = parent
.join(".codewhale-worktrees")
.join(format!("{repo_name}-{slug}"));
if path.exists() {
anyhow::bail!("worktree path already exists: {}", path.display());
}
Ok(codewhale_lane::WorktreeProvision {
repo_root,
branch: format!("codex/{slug}"),
path,
base_ref: Some("HEAD".to_string()),
})
}
pub(crate) async fn provision_launch_worktree(
workspace: PathBuf,
requested: String,
) -> Result<PathBuf> {
let spec = launch_worktree_spec(&workspace, &requested)?;
let provisioned =
tokio::task::spawn_blocking(move || codewhale_lane::provision_worktree(&spec))
.await
.context("new worktree task failed")??;View on GitHub (pinned to 0c42157ee5)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/tui/ui/session_state.rs:580 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/f4b34f6092a93204.
Report an issue: GitHub.