paperclipai/paperclip · error

Cannot rebuild the git worktree: the base project checkout p

Error message

Cannot rebuild the git worktree: the base project checkout path is empty.

What it means

Worktree rebuild needs to create a git worktree off the base project checkout, but the recorded base checkout path exists yet is empty. The pre-spawn guard throws this clear cause instead of the confusing 'spawn git ENOENT'-style failure that would follow.

Source

Thrown at server/src/services/workspace-runtime.ts:3397

    baseRefSha: readRecordedBaseRefSha(input.workspace.metadata),
  };
  const provisionCommand = asString(input.workspace.config?.provisionCommand, "").trim();

  if (strategy !== "git_worktree") {
    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,

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. Configure a base project checkout path for the workspace before rebuilding the worktree.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/services/workspace-runtime.ts:3338 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/7532348adbc64ff1. Report an issue: GitHub.