{"record":{"id":"6291ec3200f8b0ea","repo":"thedotmack/claude-mem","slug":"github-cli-is-not-available-install-gh-and-try-ag","errorCode":null,"errorMessage":"GitHub CLI is not available. Install gh and try again.","messagePattern":"GitHub CLI is not available\\. Install gh and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/pr-babysit-status.ts","lineNumber":136,"sourceCode":"\nfunction parseJson<T>(raw: string, label: string): T {\n  try {\n    return JSON.parse(raw) as T;\n  } catch (error) {\n    const message = error instanceof Error ? error.message : String(error);\n    throw new Error(`Could not parse ${label} JSON: ${message}`);\n  }\n}\n\nfunction checkPrerequisites() {\n  const git = runCommand(['git', 'rev-parse', '--is-inside-work-tree']);\n  if (git.exitCode !== 0 || git.stdout.trim() !== 'true') {\n    throw new Error('Not in a git repository. Run this from a checked-out repo.');\n  }\n\n  const ghVersion = runCommand(['gh', '--version']);\n  if (ghVersion.exitCode !== 0) {\n    throw new Error('GitHub CLI is not available. Install gh and try again.');\n  }\n\n  const auth = runCommand(['gh', 'auth', 'status']);\n  if (auth.exitCode !== 0) {\n    throw new Error(`GitHub CLI is not authenticated. Run \"gh auth login\".\\n${auth.stderr || auth.stdout}`.trim());\n  }\n}\n\nfunction targetArgs(prArg?: string): string[] {\n  return prArg ? [prArg] : [];\n}\n\nfunction fetchPr(prArg?: string): PullRequest {\n  const fields = [\n    'number',\n    'title',\n    'url',\n    'headRefOid',","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/scripts/pr-babysit-status.ts#L118-L154","documentation":"Thrown by checkPrerequisites() when `gh --version` exits non-zero, indicating the GitHub CLI binary is not installed or not executable on PATH. It is checked after the git precondition and before auth, since every subsequent operation depends on gh.","triggerScenarios":"gh is not installed at all. gh is installed but not on PATH in the current shell (common after a brew/winget install without shell restart). The gh binary exists but lacks execute permission. A broken gh installation that crashes on --version.","commonSituations":"Fresh CI runner without gh preinstalled. A new local machine where gh was installed via a package manager whose bin directory isn't on PATH yet. A container image that omits gh.","solutions":["Install gh (brew install gh / winget install GitHub.cli / apt install gh) and confirm `gh --version` works.","Open a new shell after install so PATH is refreshed, or source the shell profile.","If gh is installed elsewhere, add its directory to PATH or invoke the script from a shell that has it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const v = runCommand(['gh', '--version']);\nif (v.exitCode !== 0) {\n  console.error('Install gh: https://cli.github.com/');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Preinstall gh in CI images and base machines.","Open a new shell after installing gh so PATH refreshes.","Call checkPrerequisites() before any gh-dependent logic."],"tags":["github","cli","dependencies","environment"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}