zeroclaw-labs/zeroclaw · error · anyhow::Error
Gemini CLI exited with non-zero status {code}. Check that Ge
Error message
Gemini CLI exited with non-zero status {code}. Check that Gemini CLI is authenticated and the CLI is supported.{stderr_note} What it means
The spawned gemini binary exited with a non-zero code. The message includes the exit code and a redacted, clipped stderr excerpt (redact_stderr caps length); the dominant causes the message itself names are missing CLI authentication and an unsupported/changed CLI version.
Source
Thrown at crates/zeroclaw-providers/src/gemini_cli.rs:222
.with_outcome(::zeroclaw_log::EventOutcome::Failure)
.with_attrs(::serde_json::json!({
"phase": "process_wait",
"error": format!("{}", err),
})),
"gemini_cli: process wait failed"
);
anyhow::Error::msg(format!("Gemini CLI process failed: {err}"))
})?;
if !output.status.success() {
let code = output.status.code().unwrap_or(-1);
let stderr_excerpt = Self::redact_stderr(&output.stderr);
let stderr_note = if stderr_excerpt.is_empty() {
String::new()
} else {
format!(" Stderr: {stderr_excerpt}")
};
anyhow::bail!(
"Gemini CLI exited with non-zero status {code}. \
Check that Gemini CLI is authenticated and the CLI is supported.{stderr_note}"
);
}
let text = String::from_utf8(output.stdout).map_err(|err| {
::zeroclaw_log::record!(
ERROR,
::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)
.with_outcome(::zeroclaw_log::EventOutcome::Failure)
.with_attrs(::serde_json::json!({
"phase": "utf8_decode",
"error": format!("{}", err),
})),
"gemini_cli: non-UTF-8 stdout"
);
anyhow::Error::msg(format!("Gemini CLI produced non-UTF-8 output: {err}"))
})?;View on GitHub (pinned to 88bb9c8533)
Solutions
- Run the same prompt manually with the CLI and complete its auth flow
- Pin or reinstall a supported gemini CLI version
- Set GEMINI_CLI_PATH to a known-good binary
- Read the appended Stderr excerpt for the CLI's own complaint
Example fix
# before: CI never authenticates the CLI - run: zeroclaw chat --provider gemini_cli "hi" # after: authenticate once, cache HOME - run: gemini --version && gemini auth login # or restore a cached auth dir - run: zeroclaw chat --provider gemini_cli "hi"
Defensive patterns
Strategy: try-catch
Validate before calling
async fn gemini_cli_healthy(binary: &str) -> bool {
tokio::process::Command::new(binary)
.arg("--version")
.output()
.await
.map(|o| o.status.success())
.unwrap_or(false)
} Type guard
fn is_gemini_cli_exit_error(e: &anyhow::Error) -> bool {
e.to_string().starts_with("Gemini CLI exited with non-zero status")
} Try / catch
match provider.chat_with_system(None, prompt, model, temp).await {
Ok(t) => Ok(t),
Err(e) if e.to_string().starts_with("Gemini CLI exited with non-zero status") => {
// read the embedded Stderr excerpt; check auth, then retry once
run_gemini_auth_check().await?;
provider.chat_with_system(None, prompt, model, temp).await
}
Err(e) => Err(e),
} Prevention
- Run the CLI's auth login during provisioning, not at chat time
- Pin the gemini CLI version and re-test after upgrades
- Set GEMINI_CLI_PATH explicitly in CI to avoid PATH drift
- Smoke-test the binary with --version at provider construction
When it happens
Trigger: invoke_cli runs after the binary spawned successfully but the CLI failed: never-authenticated gemini CLI, expired credentials, major-version flag changes, or a sandboxed CI environment without HOME/auth cache.
Common situations: Fresh machine or CI container where gemini was installed but never logged in; CLI auto-updated overnight and changed behavior; GEMINI_CLI_PATH pointing at a wrapper script that fails early.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Gemini CLI model_provider received non-finite temperature va
- temperature unsupported by Gemini CLI: {temperature}. Suppor
- Jira get_ticket failed ({status}): {}
- Jira list_projects failed ({status}): {}
- Jira myself failed ({status}): {}
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/7822090234b38cac.
Report an issue: GitHub.