stablyai/orca · error · Error

Failed to force delete worktree at ${canonicalWorktreePath}.

Error message

Failed to force delete worktree at ${canonicalWorktreePath}.

What it means

Thrown in the local removeWorktree catch block when the Git removal error is not recoverable by the Windows recovery path and not an orphan-classified error. formatWorktreeRemovalError with force=true yields the 'Failed to force delete...' prefix plus the underlying Git stderr/stdout. This is the terminal failure after all recovery options are exhausted.

Source

Thrown at src/main/ipc/worktrees.ts:2936

                  args.worktreeId,
                  removedPushTarget,
                  store,
                  localWorktreeGitOptions
                )
                runtime.clearOptimisticReconcileToken(args.worktreeId)
                removeWorktreeMetadataAndTransientState(store, args.worktreeId, removalHostId)
                preservedBranchCleanupByScope.delete(
                  preservedBranchCleanupScopeKey({
                    worktreeId: args.worktreeId,
                    hostId: removalHostId
                  })
                )
                invalidateAuthorizedRootsCache()
                notifyWorktreesChanged(mainWindow, repoId)
                removalCompleted = true
                return {}
              } else {
                throw new Error(
                  formatWorktreeRemovalError(error, canonicalWorktreePath, args.force ?? false)
                )
              }
            }
            removalCompleted = true
          } finally {
            await removalGate.finish(removalCompleted)
          }
          await cleanupUnusedWorktreePushTargetRemote(
            repo.path,
            args.worktreeId,
            removedPushTarget,
            store,
            localWorktreeGitOptions
          )
          rememberPreservedBranchCleanupTarget(
            args.worktreeId,
            removalHostId,

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Close all programs holding files in the worktree (editors, terminals, watchers) and retry.
  2. On Windows/WSL, check for path-too-long or locked handles; retry after releasing them.
  3. Inspect the appended Git stderr in the message for the root cause and address it (permissions, disk, antivirus).
Defensive patterns

Strategy: try-catch

Type guard

function isForceDeleteFailure(e: unknown): boolean {
  return e instanceof Error && e.message.startsWith('Failed to force delete worktree')
}

Try / catch

try {
  await invoke('worktrees:remove', { worktreeId, force: true })
} catch (e) {
  if (isForceDeleteFailure(e)) {
    // Close programs holding handles, free locks, then surface the appended Git error to the user.
  } else throw e
}

Prevention

When it happens

Trigger: A forced worktrees:remove where `git worktree remove` fails for a reason other than orphan status or a Windows-transient deregistration — e.g. permission error, path-too-long, busy file handle, or filesystem I/O error.

Common situations: Windows file handles (editors, terminals, AV) lock files during recursive delete; WSL/Windows path-length limits; permission/ownership issues on the worktree directory; SSH-backed host I/O errors.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/7048297c4dd80586. Report an issue: GitHub.