{"record":{"id":"0ea86d16414def36","repo":"paperclipai/paperclip","slug":"failed-to-fetch-from-remote-remote-extract","errorCode":null,"errorMessage":"Failed to fetch from remote \"${remote}\": ${extractExecSyncErrorMessage(error) ?? String(error)}","messagePattern":"Failed to fetch from remote \"(.+?)\": (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":1835,"sourceCode":"  const name = resolveWorktreeMakeName(nameArg);\n  const startPoint = resolveWorktreeStartPoint(opts.startPoint);\n  const sourceCwd = process.cwd();\n  const sourceConfigPath = resolveSourceConfigPath(opts);\n  const targetPath = resolveWorktreeMakeTargetPath(name);\n  if (existsSync(targetPath)) {\n    throw new Error(`Target path already exists: ${targetPath}`);\n  }\n\n  mkdirSync(path.dirname(targetPath), { recursive: true });\n  if (startPoint) {\n    const [remote] = startPoint.split(\"/\", 1);\n    try {\n      execFileSync(\"git\", [\"fetch\", remote], {\n        cwd: sourceCwd,\n        stdio: [\"ignore\", \"pipe\", \"pipe\"],\n      });\n    } catch (error) {\n      throw new Error(\n        `Failed to fetch from remote \"${remote}\": ${extractExecSyncErrorMessage(error) ?? String(error)}`,\n      );\n    }\n  }\n\n  const worktreeArgs = resolveGitWorktreeAddArgs({\n    branchName: name,\n    targetPath,\n    branchExists: !startPoint && localBranchExists(sourceCwd, name),\n    startPoint,\n  });\n\n  const spinner = p.spinner();\n  spinner.start(`Creating git worktree at ${targetPath}...`);\n  try {\n    execFileSync(\"git\", worktreeArgs, {\n      cwd: sourceCwd,\n      stdio: [\"ignore\", \"pipe\", \"pipe\"],","sourceCodeStart":1817,"sourceCodeEnd":1853,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L1817-L1853","documentation":"Thrown when `git fetch <remote>` fails during worktreeMakeCommand. The startPoint string is split on '/' to derive the remote name (e.g. \"origin/main\" -> \"origin\"); if `git fetch` for that remote exits non-zero, the execFileSync error is surfaced via extractExecSyncErrorMessage. This fetch is only attempted when a startPoint (remote branch) is supplied so the worktree can be created from up-to-date remote refs.","triggerScenarios":"Passing `--start-point origin/feat-x` when offline or when the remote is unreachable; the remote name in the start point does not exist (`git remote -v`); network/firewall blocks the fetch; auth failure for a private remote; malformed start point with no valid remote segment.","commonSituations":"No network / VPN down; remote URL changed but git config still points at old URL; SSH key or token not configured for the remote; typo in the start-point remote prefix.","solutions":["Confirm the remote exists and is reachable: `git remote -v` then `git fetch <remote>` manually to see the real git error.","Fix auth (SSH key, credential helper, PAT) for the remote.","If you don't need the latest remote ref, omit --start-point to branch from the current HEAD instead.","Retry once transient network issues are resolved."],"exampleFix":"// before\npaperclipai worktree:make feat-x --start-point origin/feat-x   # fetch fails\n// after (branch from local HEAD, no fetch needed)\npaperclipai worktree:make feat-x","handlingStrategy":"try-catch","validationCode":"import { execFileSync } from \"node:child_process\";\nfunction remoteFetchable(remote: string, cwd: string): boolean {\n  try {\n    execFileSync(\"git\", [\"fetch\", remote, \"--dry-run\"], { cwd, stdio: \"ignore\" });\n    return true;\n  } catch { return false; }\n}","typeGuard":"function startPointHasRemote(sp: string): boolean {\n  return /^[A-Za-z0-9._-]+\\//.test(sp) && sp.split(\"/\")[0].length > 0;\n}","tryCatchPattern":"try { /* fetch */ }\ncatch (err) {\n  if (/Failed to fetch from remote/.test(String((err as Error).message))) {\n    // fall back: create worktree from local HEAD by dropping --start-point\n  } else throw err;\n}","preventionTips":["Confirm `git remote -v` lists the remote and `git fetch <remote>` works before using --start-point.","Ensure network/VPN and git credentials are configured.","Omit --start-point to branch from local HEAD when remote access is unavailable."],"tags":["worktree","git","network","cli"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}