stablyai/orca · error · Error
Could not find an available worktree name for "${sanitizedNa
Error message
Could not find an available worktree name for "${sanitizedName}". Pick a different worktree name. What it means
Local worktree create exhausted all suffixed candidate paths with neither a branch conflict nor a PR conflict recorded — resolved stayed false and both lastExistingReviewNumber and lastBranchConflictKind are null. This is a pure path-collision failure: every candidate worktreePath already exists on disk (existsSync true), unrelated to branches or reviews.
Source
Thrown at src/main/ipc/worktree-remote.ts:2207
}
resolved = true
break
}
if (!resolved) {
// Why: every suffix collided; reject with a specific reason so the user sees why create failed instead of a generic error or hung spinner.
if (lastExistingReviewNumber !== null) {
throw new Error(
`Branch "${branchName}" already has PR #${lastExistingReviewNumber}. Pick a different ${branchConflictSubject}.`
)
}
if (lastBranchConflictKind) {
throw new Error(
`Branch "${branchName}" already exists ${lastBranchConflictKind === 'local' ? 'locally' : 'on a remote'}. Pick a different ${branchConflictSubject}.`
)
}
throw new Error(
`Could not find an available worktree name for "${sanitizedName}". Pick a different worktree name.`
)
}
validateWorkspaceLineageParentBeforeCreate(
store,
args.parentWorkspace,
worktreeWorkspaceKey(`${repo.id}::${worktreePath}`)
)
if (remoteTrackingRefresh) {
await timing.time('refresh_base_ref', async () => {
const result = await remoteTrackingRefresh.promise
if (!result.ok && !remoteTrackingRefresh.hadLocalBaseRef) {
// Why: only block create when the refresh failed AND there's no local base ref; an existing (possibly stale) ref keeps worktree add viable.
throw new Error(
`Could not refresh base ref "${baseBranch}" from "${remoteTrackingRefresh.base.remote}". Check your network and try again.`
)View on GitHub (pinned to 1136503c6a)
Solutions
- Pick a more unique worktree name.
- Remove orphaned worktree directories left by failed deletes (git worktree prune, then rm the folders).
- Widen the candidate suffix range or change the worktree path template.
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs'
for (const candidate of buildNameCandidates(sanitizedName)) {
const p = resolveWorktreePath(repo, candidate)
if (!existsSync(p)) return { ok: true, worktreePath: p }
}
return { ok: false, error: `All candidate paths for "${sanitizedName}" already exist.` } Try / catch
catch (err) {
if (err instanceof Error && err.message.startsWith('Could not find an available worktree name')) {
promptForDifferentWorktreeName()
} else { throw err }
} Prevention
- Choose distinctive worktree names.
- Prune orphaned worktree dirs (git worktree prune) after failed deletes.
- Expand the naming template suffix range.
When it happens
Trigger: Local create loop where existsSync(worktreePath) is true for every candidate and no branch/PR conflict was recorded. Reached at worktree-remote.ts:2207 (final fallback throw).
Common situations: Many worktrees with the same base name already on disk; orphaned directories from crashed/partial deletes; very long names truncating into collisions; suffix range too small for the number of existing worktrees.
Related errors
- Could not find an available remote worktree path for "${sani
- Branch "${branchName}" already has PR #${lastExistingReviewN
- Branch "${branchName}" already exists ${lastBranchConflictKi
- Could not refresh base ref "${baseBranch}" from "${remoteTra
- Base ref "${baseBranch}" was not found after fetching.
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/0361f75471795484.
Report an issue: GitHub.