thedotmack/claude-mem · error · Error

GitHub CLI is not available. Install gh and try again.

Error message

GitHub CLI is not available. Install gh and try again.

What it means

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.

Source

Thrown at scripts/pr-babysit-status.ts:136

function parseJson<T>(raw: string, label: string): T {
  try {
    return JSON.parse(raw) as T;
  } catch (error) {
    const message = error instanceof Error ? error.message : String(error);
    throw new Error(`Could not parse ${label} JSON: ${message}`);
  }
}

function checkPrerequisites() {
  const git = runCommand(['git', 'rev-parse', '--is-inside-work-tree']);
  if (git.exitCode !== 0 || git.stdout.trim() !== 'true') {
    throw new Error('Not in a git repository. Run this from a checked-out repo.');
  }

  const ghVersion = runCommand(['gh', '--version']);
  if (ghVersion.exitCode !== 0) {
    throw new Error('GitHub CLI is not available. Install gh and try again.');
  }

  const auth = runCommand(['gh', 'auth', 'status']);
  if (auth.exitCode !== 0) {
    throw new Error(`GitHub CLI is not authenticated. Run "gh auth login".\n${auth.stderr || auth.stdout}`.trim());
  }
}

function targetArgs(prArg?: string): string[] {
  return prArg ? [prArg] : [];
}

function fetchPr(prArg?: string): PullRequest {
  const fields = [
    'number',
    'title',
    'url',
    'headRefOid',

View on GitHub (pinned to d768ba3643)

Solutions

  1. Install gh (brew install gh / winget install GitHub.cli / apt install gh) and confirm `gh --version` works.
  2. Open a new shell after install so PATH is refreshed, or source the shell profile.
  3. If gh is installed elsewhere, add its directory to PATH or invoke the script from a shell that has it.
Defensive patterns

Strategy: validation

Validate before calling

const v = runCommand(['gh', '--version']);
if (v.exitCode !== 0) {
  console.error('Install gh: https://cli.github.com/');
  process.exit(1);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12). Data as JSON: /api/errors/6291ec3200f8b0ea. Report an issue: GitHub.