{"record":{"id":"bba92fb454d5336e","repo":"paperclipai/paperclip","slug":"target-path-already-exists-but-is-not-a-registered","errorCode":null,"errorMessage":"Target path already exists but is not a registered git worktree: ${targetPath}","messagePattern":"Target path already exists but is not a registered git worktree: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":1006,"sourceCode":"      rootPath: existing.worktree,\n      configPath: path.resolve(existing.worktree, \".paperclip\", \"config.json\"),\n      label: existing.branchLabel,\n      branchName: existing.branchLabel === \"(detached)\" ? null : existing.branchLabel,\n      created: false,\n    };\n  }\n\n  const repoRoot = resolvePrimaryGitRepoRoot(cwd);\n  const branchName = validateGitBranchName(repoRoot, input.selector);\n  const targetPath = path.resolve(\n    repoRoot,\n    \".paperclip\",\n    \"worktrees\",\n    resolveRepairWorktreeDirName(branchName),\n  );\n\n  if (existsSync(targetPath)) {\n    throw new Error(`Target path already exists but is not a registered git worktree: ${targetPath}`);\n  }\n\n  mkdirSync(path.dirname(targetPath), { recursive: true });\n\n  const spinner = p.spinner();\n  spinner.start(`Creating git worktree for ${branchName}...`);\n  try {\n    execFileSync(\"git\", resolveGitWorktreeAddArgs({\n      branchName,\n      targetPath,\n      branchExists: localBranchExists(repoRoot, branchName),\n    }), {\n      cwd: repoRoot,\n      stdio: [\"ignore\", \"pipe\", \"pipe\"],\n    });\n    spinner.stop(`Created git worktree at ${targetPath}.`);\n  } catch (error) {\n    spinner.stop(pc.red(\"Failed to create git worktree.\"));","sourceCodeStart":988,"sourceCodeEnd":1024,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L988-L1024","documentation":"Repair-safety guard: the target directory for a repaired worktree already exists on disk but is not registered in `git worktree list`, meaning it is an unrelated directory the repair flow must not overwrite or adopt.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:990 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a different target path, or register/remove the existing directory at that path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}