paperclipai/paperclip · error
Cannot rebuild the git worktree: the base project checkout d
Error message
Cannot rebuild the git worktree: the base project checkout directory does not exist.
What it means
Worktree rebuild validated the base project checkout and its recorded baseCwd does not exist on disk. The pre-spawn guard gives a precise cause (missing base checkout) before the git worktree add would fail opaquely.
Source
Thrown at server/src/services/workspace-runtime.ts:3402
if (!await directoryExists(cwd)) {
return null;
}
return realized;
}
// Validate the base checkout before the git spawn. A missing or empty base
// path makes the "git" spawn fail with a raw "spawn git ENOENT" error. That
// error hides the real cause: the base project checkout is not on disk.
// Throw a clear cause first so a future failure names the missing checkout.
// Keep the persisted path exact. A directory name can start or end with a
// space, so a trim would change a valid checkout path.
const baseCwd = asString(input.base.baseCwd, "");
if (!baseCwd) {
throw new Error(
"Cannot rebuild the git worktree: the base project checkout path is empty.",
);
}
if (!await directoryExists(baseCwd)) {
throw new Error(
"Cannot rebuild the git worktree: the base project checkout directory does not exist.",
);
}
const repoRoot = await runGit(["rev-parse", "--show-toplevel"], baseCwd);
const recordedBaseRefSha = readRecordedBaseRefSha(input.workspace.metadata);
if (await directoryExists(cwd)) {
const reuseBaseRef = input.workspace.baseRef ?? input.base.repoRef ?? null;
const reuseWorktreePath = realized.worktreePath ?? cwd;
const repairWarnings: string[] = [];
if (await isGitCheckout(reuseWorktreePath)) {
const coherence = await ensureGitWorktreeBranchCoherent({
db: input.db ?? null,
repoRoot,
worktreePath: reuseWorktreePath,
expectedBranchName: realized.branchName,
sourceIssue: input.issue,
executionWorkspaceId: input.workspace.id ?? null,
heartbeatRunId: input.heartbeatRunId ?? null,View on GitHub (pinned to a7e689b3c3)
Solutions
- Restore or re-clone the base project checkout directory, then retry the worktree rebuild.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/src/services/workspace-runtime.ts:3343 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-18).
Data as JSON: /api/errors/2ac1b67984c221ea.
Report an issue: GitHub.