{"record":{"id":"d7ace95d0d1fd50e","repo":"EveryInc/compound-engineering-plugin","slug":"failed-to-clone-branch-branch-from-source","errorCode":null,"errorMessage":"Failed to clone branch '${branch}' from ${source}. ${stderr.trim()}","messagePattern":"Failed to clone branch '(.+?)' from (.+?)\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/commands/plugin-path.ts","lineNumber":90,"sourceCode":"      const manifest = JSON.parse(raw) as { name?: string }\n      if (manifest.name === pluginName) return repoDir\n    } catch {\n      // Fall through to the legacy multi-plugin layout.\n    }\n  }\n\n  return path.join(repoDir, \"plugins\", pluginName)\n}\n\nasync function cloneBranch(source: string, destination: string, branch: string): Promise<void> {\n  const proc = Bun.spawn([\"git\", \"clone\", \"--depth\", \"1\", \"--branch\", branch, source, destination], {\n    stdout: \"pipe\",\n    stderr: \"pipe\",\n  })\n  const exitCode = await proc.exited\n  const stderr = await new Response(proc.stderr).text()\n  if (exitCode !== 0) {\n    throw new Error(`Failed to clone branch '${branch}' from ${source}. ${stderr.trim()}`)\n  }\n}\n\nasync function fetchAndCheckout(repoDir: string, branch: string): Promise<void> {\n  const fetch = Bun.spawn([\"git\", \"fetch\", \"origin\", branch], {\n    cwd: repoDir,\n    stdout: \"pipe\",\n    stderr: \"pipe\",\n  })\n  const fetchExit = await fetch.exited\n  const fetchErr = await new Response(fetch.stderr).text()\n  if (fetchExit !== 0) {\n    throw new Error(`Failed to fetch branch '${branch}'. ${fetchErr.trim()}`)\n  }\n\n  const reset = Bun.spawn([\"git\", \"reset\", \"--hard\", `origin/${branch}`], {\n    cwd: repoDir,\n    stdout: \"pipe\",","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/EveryInc/compound-engineering-plugin/blob/c9c10f8c75412c7232cb2bd663e5fd1cea98d84e/src/commands/plugin-path.ts#L72-L108","documentation":"`plugin-path --branch <name>` clones the source repository at that branch via `git clone --branch`. When git exits non-zero during the clone, the command wraps git's stderr into this error. The most common cause is the branch not existing on the remote, but any clone failure (network, auth, bad URL) lands here.","triggerScenarios":"Running `plugin-path <plugin> --branch <branch>` when: the branch does not exist on the remote (`Remote branch <branch> not found`), the remote is unreachable, credentials are missing for a private repo, or COMPOUND_PLUGIN_GITHUB_SOURCE is an invalid URL.","commonSituations":"Branch typo; branch was deleted/rebased away on the remote; testing a feature branch that was force-pushed under a new name; offline; private fork needing auth.","solutions":["Read the git stderr in the message; if it says the branch was not found, list branches: `git ls-remote --heads <source>`.","Fix the --branch spelling or use the default (no --branch) clone.","Check network/proxy and git credentials for the remote.","Verify COMPOUND_PLUGIN_GITHUB_SOURCE (if set) points at the correct repo."],"exampleFix":"// before\nplugin-path compound-engineering --branch feat/new-agents  # deleted branch\n// after\nplugin-path compound-engineering  # default branch","handlingStrategy":"validation","validationCode":"// Check the branch exists on the remote before plugin-path --branch\nconst out = Bun.spawnSync([\"git\", \"ls-remote\", \"--heads\", source, branch])\nif (out.exitCode !== 0 || !out.stdout.toString().trim()) throw new Error(`Branch ${branch} not found on ${source}`)","typeGuard":null,"tryCatchPattern":"try {\n  const p = await pluginPath(plugin, { branch })\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Failed to clone branch\")) {\n    console.error(`Clone failed for branch ${branch}: ${e.message}`)\n    // fall back to default branch\n    return pluginPath(plugin)\n  } else throw e\n}","preventionTips":["Verify the branch name with `git ls-remote --heads <source>` before using --branch.","Don't reference feature branches that may be deleted after merge; use main for stable installs.","Keep git credentials and network access working for the remote."],"tags":["git","clone","branch","network"],"backgroundTag":"git-branch-not-found","analyzedSha":"c9c10f8c75412c7232cb2bd663e5fd1cea98d84e","analyzedAt":"2026-08-31T15:18:07.959Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}