thedotmack/claude-mem · error · Error
GitHub CLI is not authenticated. Run "gh auth login". ${auth
Error message
GitHub CLI is not authenticated. Run "gh auth login".
${auth.stderr || auth.stdout} What it means
Thrown by checkPrerequisites() when `gh auth status` exits non-zero. gh is present but not authenticated, so every subsequent gh api/pr call would fail. The message embeds gh's own auth-status output so the user sees the exact token state.
Source
Thrown at scripts/pr-babysit-status.ts:141
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',
'baseRefName',
'state',
'isDraft',
'mergeable',
'mergeStateStatus',View on GitHub (pinned to d768ba3643)
Solutions
- Run `gh auth login` interactively (or `gh auth login --with-token < token.txt`) and re-run the script.
- If using an enterprise host, run `gh auth login --hostname <host>`.
- If the token was revoked, generate a new one and re-login.
- Confirm with `gh auth status` that it reports active before retrying.
Defensive patterns
Strategy: validation
Validate before calling
const a = runCommand(['gh', 'auth', 'status']);
if (a.exitCode !== 0) {
console.error('Run `gh auth login` first.');
process.exit(1);
} Prevention
- Run `gh auth login` (or `gh auth login --with-token`) before invoking the script.
- For enterprise hosts use `gh auth login --hostname <host>`.
- Refresh tokens before they expire; check `gh auth status` in CI periodically.
When it happens
Trigger: gh was never logged in. The stored token expired (OAuth) or was revoked. The token lacks a host mapping (enterprise vs github.com). gh auth status needs network to validate and the host is unreachable, returning non-zero. A token-keyring that is locked.
Common situations: First run on a new machine. A long-lived CI runner whose token expired. Switching between github.com and an enterprise host without `gh auth switch`. A revoked PAT used via GH_TOKEN.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- gh ${args.join(' ')} failed: ${detail}
- GitHub CLI is not available. Install gh and try again.
- Could not parse ${label} JSON: ${message}
- Not in a git repository. Run this from a checked-out repo.
- Unknown Claude model: ${options.model}. Allowed: ${[...allow
AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12).
Data as JSON: /api/errors/e967e00bd57003be.
Report an issue: GitHub.