NousResearch/hermes-agent · error
gh pr create failed (is gh installed and authenticated?)
Error message
gh pr create failed (is gh installed and authenticated?)
What it means
Thrown by reviewCreatePr in the desktop app's git-review IPC layer after runGh(['pr','create','--fill']) returned a non-zero exit. The message is a guess: gh either isn't on PATH, isn't authenticated, or refused to create the PR for a repo/branch reason. The preceding reviewPush() failure is deliberately swallowed, so a push failure (no permission, no remote) surfaces here too.
Source
Thrown at apps/desktop/electron/git-review-ops.ts:773
} catch {
// A malformed chunk drops its branches; the rest still resolve.
}
}
return { ghReady: true, prs }
}
// Create a PR for the current branch (pushing first so gh has a remote ref),
// letting gh fill title/body from the commits. Returns the new PR url.
async function reviewCreatePr(repoPath, gitBin, ghBin) {
const cwd = resolveRequestedPathForIpc(repoPath, { purpose: 'Review create PR' })
await reviewPush(repoPath, gitBin).catch(() => undefined)
const created = await runGh(['pr', 'create', '--fill'], cwd, ghBin)
if (!created.ok) {
throw new Error('gh pr create failed (is gh installed and authenticated?)')
}
const url = created.stdout.trim().split('\n').filter(Boolean).pop() || ''
return { url }
}
// Compact working-tree status for the composer coding rail: branch, ahead/behind,
// per-state change counts, +/- vs HEAD, and a capped changed-file list.
async function repoStatus(repoPath, gitBin) {
let cwd
try {
cwd = resolveRequestedPathForIpc(repoPath, { purpose: 'Repo status' })
} catch {
return null
}
View on GitHub (pinned to c896c09c42)
Solutions
- Run `gh --version` and `gh auth status` in a terminal; if either fails, install gh and run `gh auth login`.
- Verify the branch actually differs from the base: `git log origin/main..HEAD --oneline` (gh pr create --fill needs at least one commit to build title/body from).
- Check that reviewPush succeeded — `git push` manually and look for permission/protected-branch errors, since the code swallows push failures.
- If gh is installed in a non-standard location, ensure the desktop app inherits a PATH that includes it (launch from a shell or fix the app's environment).
- Run `gh pr create --fill` by hand in the repo to see gh's real stderr, which the wrapper discards.
Example fix
// before
const created = await runGh(['pr', 'create', '--fill'], cwd, ghBin)
if (!created.ok) {
throw new Error('gh pr create failed (is gh installed and authenticated?)')
}
// after — surface gh's stderr so users can diagnose
const created = await runGh(['pr', 'create', '--fill'], cwd, ghBin)
if (!created.ok) {
const detail = (created.stderr || created.stdout || '').trim().split('\n').pop()
throw new Error(`gh pr create failed (is gh installed and authenticated?)${detail ? `: ${detail}` : ''}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
const { execFileSync } = require('child_process')
function ghReady(ghBin) {
try {
execFileSync(ghBin || 'gh', ['auth', 'status'], { stdio: 'ignore' })
return true
} catch {
return false
}
} Try / catch
try {
const { url } = await reviewCreatePr(repoPath, gitBin, ghBin)
} catch (e) {
if (/gh pr create failed/.test(e.message)) {
showHint('Run `gh auth login`, verify the branch has commits vs base, then retry.')
} else throw e
} Prevention
- Authenticate gh before using PR actions
- Ensure the branch has at least one commit the base lacks
- Never swallow push failures silently before PR creation
When it happens
Trigger: IPC 'Review create PR' action while: gh binary missing from PATH; gh installed but `gh auth status` fails; the branch has no commits differing from the base (--fill finds no commit message and gh errors); the push was rejected (protected branch, no write access) so gh sees no remote ref; no base branch can be inferred on a repo with non-default branch names.
Common situations: Corporate machines where gh is not provisioned; fresh clones where the user authenticated git via SSH but never ran `gh auth login`; creating a PR from a branch identical to main; forks where the push went to the fork but gh's default repo resolution points at upstream.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Branch name is required.
- Missing URL
- Invalid external URL
- Invalid preview URL
- Could not create directory: ${error.message}
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/bf252547472664de.
Report an issue: GitHub.