EveryInc/compound-engineering-plugin · error · Error
Failed to fetch branch '${branch}'. ${fetchErr.trim()}
Error message
Failed to fetch branch '${branch}'. ${fetchErr.trim()} What it means
When the requested branch is already present in an existing local clone, `plugin-path` refreshes it with `git fetch origin <branch>` inside the repo and then hard-resets. This error fires when the fetch exits non-zero, with git's stderr embedded — typically because the branch no longer exists on the remote or the remote is unreachable.
Source
Thrown at src/commands/plugin-path.ts:103
stderr: "pipe",
})
const exitCode = await proc.exited
const stderr = await new Response(proc.stderr).text()
if (exitCode !== 0) {
throw new Error(`Failed to clone branch '${branch}' from ${source}. ${stderr.trim()}`)
}
}
async function fetchAndCheckout(repoDir: string, branch: string): Promise<void> {
const fetch = Bun.spawn(["git", "fetch", "origin", branch], {
cwd: repoDir,
stdout: "pipe",
stderr: "pipe",
})
const fetchExit = await fetch.exited
const fetchErr = await new Response(fetch.stderr).text()
if (fetchExit !== 0) {
throw new Error(`Failed to fetch branch '${branch}'. ${fetchErr.trim()}`)
}
const reset = Bun.spawn(["git", "reset", "--hard", `origin/${branch}`], {
cwd: repoDir,
stdout: "pipe",
stderr: "pipe",
})
const resetExit = await reset.exited
const resetErr = await new Response(reset.stderr).text()
if (resetExit !== 0) {
throw new Error(`Failed to reset to origin/${branch}. ${resetErr.trim()}`)
}
}
function resolveGitHubSource(): string {
const override = process.env.COMPOUND_PLUGIN_GITHUB_SOURCE
if (override && override.trim()) return override.trim()
return "https://github.com/EveryInc/compound-engineering-plugin"View on GitHub (pinned to c9c10f8c75)
Solutions
- Confirm the branch still exists: `git ls-remote --heads <source> <branch>`; if deleted, pick another branch.
- Delete the cached clone/target directory so the next run does a fresh clone instead of a fetch.
- Fix network/proxy or refresh git credentials, then retry.
- If COMPOUND_PLUGIN_GITHUB_SOURCE changed recently, clear the old clone that still points at the previous remote.
Example fix
// before (branch deleted upstream, cached clone fetch fails) plugin-path compound-engineering --branch feat/old-branch // after rm -rf <cached-target-dir> && plugin-path compound-engineering
Defensive patterns
Strategy: fallback
Validate before calling
// Ensure the remote branch still exists before refreshing a cached clone
const out = Bun.spawnSync(["git", "ls-remote", "--heads", source, branch])
if (!out.stdout.toString().trim()) console.warn(`Branch ${branch} gone from remote; use a fresh clone or another branch`) Try / catch
try {
const p = await pluginPath(plugin, { branch })
} catch (e) {
if (e instanceof Error && e.message.startsWith("Failed to fetch branch")) {
// stale cache: wipe and re-clone
fs.rmSync(targetDir, { recursive: true, force: true })
return pluginPath(plugin, { branch })
} else throw e
} Prevention
- Delete cached clones when switching COMPOUND_PLUGIN_GITHUB_SOURCE or after branch deletions.
- Check the branch still exists on the remote before re-running.
- Avoid concurrent runs against the same target directory.
When it happens
Trigger: Re-running `plugin-path --branch <name>` against a cached clone when: the remote branch was deleted (fetch fails), network/auth failure contacting origin, or the source override changed so 'origin' points somewhere else.
Common situations: Feature branch merged and deleted upstream; stale cached clone from a previous run; VPN/proxy down; expired GitHub credentials.
Related errors
- Failed to clone ${source}. ${stderr.trim()}
- Failed to clone branch '${branch}' from ${source}. ${stderr.
- Failed to reset to origin/${branch}. ${resetErr.trim()}
- ${command} ${args.join(" ")} failed: ${detail}
AI-assisted analysis of EveryInc/compound-engineering-plugin@c9c10f8c75 (2026-08-31).
Data as JSON: /api/errors/d22226cfe16b2e1e.
Report an issue: GitHub.