{"record":{"id":"71f44b540636bdd7","repo":"jackwener/OpenCLI","slug":"failed-to-clone-plugin-geterrormessage-err","errorCode":null,"errorMessage":"Failed to clone plugin: ${getErrorMessage(err)}","messagePattern":"Failed to clone plugin: (.+?)","errorType":"exception","errorClass":"PluginError","httpStatus":null,"severity":"error","filePath":"src/plugin.ts","lineNumber":239,"sourceCode":"\nfunction createSiblingTempPath(dest: string, kind: 'tmp' | 'bak'): string {\n  const suffix = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n  return path.join(path.dirname(dest), `.${path.basename(dest)}.${kind}-${suffix}`);\n}\n\nfunction cloneRepoToTemp(cloneUrl: string): string {\n  const tmpCloneDir = path.join(\n    os.tmpdir(),\n    `opencli-clone-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`,\n  );\n\n  try {\n    execFileSync('git', ['clone', '--depth', '1', cloneUrl, tmpCloneDir], {\n      encoding: 'utf-8',\n      stdio: ['pipe', 'pipe', 'pipe'],\n    });\n  } catch (err) {\n    throw new PluginError(`Failed to clone plugin: ${getErrorMessage(err)}`, 'Check the repository URL and your network connection.');\n  }\n\n  return tmpCloneDir;\n}\n\nfunction withTempClone<T>(cloneUrl: string, work: (cloneDir: string) => T): T {\n  const tmpCloneDir = cloneRepoToTemp(cloneUrl);\n  try {\n    return work(tmpCloneDir);\n  } finally {\n    try { fs.rmSync(tmpCloneDir, { recursive: true, force: true }); } catch {}\n  }\n}\n\nfunction resolveRemotePluginSource(lockEntry: LockEntry | undefined, dir: string): string {\n  const source = resolvePluginSource(lockEntry, dir);\n  if (!source || source.kind === 'local') {\n    throw new Error(`Unable to determine remote source for plugin at ${dir}`);","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/plugin.ts#L221-L257","documentation":"cloneRepoToTemp runs `git clone --depth 1 <url>` into a temp dir via execFileSync. If git exits non-zero (bad URL, auth failure, network outage, missing git binary), the error is wrapped in a PluginError with the underlying git message. opencli throws this because a plugin cannot be installed or updated without cloning its source repository.","triggerScenarios":"installPlugin(source) or updatePlugin(name) with a git/monorepo source calls withTempClone -> cloneRepoToTemp; thrown when git clone fails: nonexistent repo, 404 on private repo without credentials, no network/DNS, proxy blocks github.com, or git is not installed.","commonSituations":"Typo in the GitHub user/repo; private repo with no SSH key or token; corporate firewall/proxy; offline laptop; git not on PATH (rare on dev machines); repo renamed or deleted.","solutions":["Verify the repository URL exists and is reachable: run `git ls-remote <cloneUrl>` manually.","Check network/proxy/VPN; configure git proxy if needed (`git config --global http.proxy`).","For private repos, set up credentials (SSH key, HTTPS token via credential helper) that match the URL scheme.","Confirm git is installed and on PATH (`git --version`).","Retry if the failure was transient (flaky network)."],"exampleFix":"// before\nawait installPlugin('github:user/typo-repo');\n// after\nawait installPlugin('github:user/correct-repo'); // verified via git ls-remote","handlingStrategy":"try-catch","validationCode":"import { execFileSync } from 'node:child_process';\nfunction canClone(url) {\n  try { execFileSync('git', ['ls-remote', url], { stdio: 'pipe' }); return true; }\n  catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  installPlugin('github:user/repo');\n} catch (err) {\n  if (err instanceof PluginError && err.message.startsWith('Failed to clone plugin')) {\n    // check URL/network, then retry\n  } else throw err;\n}","preventionTips":["Verify repo URLs with `git ls-remote` before installing programmatically.","Keep git installed and credentials (SSH keys / credential helper) configured.","Check network/proxy reachability to the git host before batch installs."],"tags":["git","network","clone-failure","plugin-install"],"backgroundTag":"git-clone-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}