aaif-goose/goose · error
Failed to authenticate using GitHub CLI.
Error message
Failed to authenticate using GitHub CLI.
What it means
goose ran interactive `gh auth login --git-protocol https` and the command executed but exited non-zero (crates/goose-cli/src/recipes/github_recipe.rs:125-128). Unlike [127], this is gh itself reporting that the login flow did not complete — the exit status is checked, and stderr from gh appears on the terminal around this error.
Source
Thrown at crates/goose-cli/src/recipes/github_recipe.rs:126
.args(["auth", "status"])
.set_no_window()
.status()
.map_err(|_| {
anyhow::anyhow!("Failed to run `gh auth status`. Make sure you have `gh` installed.")
})?;
if status.success() {
return Ok(());
}
println!("GitHub CLI is not authenticated. Launching `gh auth login`...");
// Run `gh auth login` interactively
let login_status = Command::new("gh")
.args(["auth", "login", "--git-protocol", "https"])
.status()
.map_err(|_| anyhow::anyhow!("Failed to run `gh auth login`"))?;
if !login_status.success() {
Err(anyhow::anyhow!("Failed to authenticate using GitHub CLI."))
} else {
Ok(())
}
}
fn temp_child_name(name: &str) -> String {
let mut child = String::with_capacity(name.len());
for ch in name.chars() {
match ch {
'/' | '\\' => child.push_str("__"),
ch if ch.is_ascii_alphanumeric() || ch == '-' || ch == '_' || ch == '.' => {
child.push(ch)
}
_ => child.push('_'),
}
}
if child.is_empty() {View on GitHub (pinned to 3810898a74)
Solutions
- Run `gh auth login` manually in an interactive terminal and complete the flow once, then re-run the goose command
- For non-interactive environments, authenticate via a token: set GH_TOKEN/GITHUB_TOKEN env var (or `gh auth login --with-token < tokenfile`) instead of the interactive flow
- Ensure stdin is attached to a TTY when interactive login is expected; do not pipe input into goose
Defensive patterns
Strategy: retry
Validate before calling
# Skip interactive login entirely in automation: provide a token export GH_TOKEN="ghp_xxx" # or GITHUB_TOKEN gh auth status >/dev/null && echo "non-interactive auth OK"
Prevention
- Complete `gh auth login` manually before running goose recipe commands
- Use GH_TOKEN for headless/CI environments instead of the interactive flow
- Never pipe stdin into goose when an interactive gh prompt may appear
When it happens
Trigger: User aborts the interactive prompt (Ctrl-C / EOF), the browser/device-code flow times out or fails, gh cannot prompt because stdin is not a TTY (piped input, some CI runners), or the chosen credentials are rejected.
Common situations: Running goose recipe commands in a non-interactive environment (CI, cron, scripts piping stdin), headless/SSH sessions without browser access where the device flow is interrupted, or an expired/revoked token causing gh to fail during login.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Failed to run `gh auth login`
- Failed to run `gh auth status`. Make sure you have `gh` inst
- Failed to clone repo: {}
- Failed to fetch repository contents using 'gh api' command (
- Failed to check directory contents: {}
AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16).
Data as JSON: /api/errors/b1bdf0a6820d3d5a.
Report an issue: GitHub.