Gemini CLI fails with `Invalid auth method selected` (exit code 41)
- Dominant language
- Go
- Stars
- 5.1k
- Forks
- 541
- Avg merge
- 5h 48m
- Merged PRs (30d)
- 773
Description
## Gemini CLI fails with `Invalid auth method selected` (exit code 41)
`engine: gemini`
### Error
```text
YOLO mode is enabled. All tool calls will be automatically approved.
Invalid auth method selected.
exitCode=41
```
### Environment
```text
gh-aw: v0.88.2
AWF: v0.28.12
Gemini CLI: 0.55.1
```
### Authentication diagnostics
Runner:
```text
GEMINI_API_KEY=SET
GEMINI_API_KEY length=53
GOOGLE_API_KEY=
GOOGLE_GENAI_USE_VERTEXAI=
GOOGLE_GENAI_USE_GCA=
```
Inside the AWF agent container:
```text
GEMINI_API_KEY=SET
GEMINI_API_KEY_LENGTH=51
GEMINI_API_KEY_PREFIX=gemini-api-key-place
GEMINI_API_BASE_URL=http://172.30.0.30:10003
GOOGLE_GEMINI_BASE_URL=http://172.30.0.30:10003
GOOGLE_API_KEY=
GOOGLE_GENAI_USE_VERTEXAI=
GOOGLE_GENAI_USE_GCA=
```
The API-key value inside the container is the AWF credential-isolation placeholder.
Gemini configuration:
```json
{
"selectedAuthType": "gemini-api-key"
}
```
### AWF status
```text
API proxy enabled: OpenAI=false, Anthropic=false, Copilot=false, Gemini=true, Vertex=false
API proxy sidecar enabled - API keys will be held securely in sidecar container
Containers started successfully
```
### Relevant generated command
```bash
gemini --yolo --skip-trust --output-format stream-json --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"
```
The AWF command also excludes the real key from the container:
```text
--exclude-env GEMINI_API_KEY
```
### Additional observations
* The Gemini API key is confirmed present on the GitHub Actions runner.
* Google AI Studio shows successful API requests.
* No `GOOGLE_API_KEY`, Vertex, or GCA authentication variables are set.
* Setting `selectedAuthType` to `gemini-api-key` does not resolve the issue.
* Gemini CLI exits during startup/authentication before producing a model response.
* No `gemini-client-error-*.json` is produced.
### Question
Is this a known compatibility issue between AWF `v0.28.12` / `gh-aw v0.88.2` and Gemini CLI `0.55.1` when using the Gemini API proxy?
Specifically, why does Gemini CLI return `Invalid auth method selected` even though the AWF agent receives the expected API-key placeholder and proxy URLs, and what is the recommended supported configuration/version combination to resolve exit code 41?
Contributor guide
Research direction
Start with the generated Gemini command and the selectedAuthType configuration, then compare the runner and AWF agent-container authentication diagnostics. Reproduce the startup failure with the stated gh-aw, AWF, and Gemini CLI versions and the Gemini API proxy enabled. Done means documenting the compatibility cause and a supported version/configuration combination that avoids exit code 41.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, go
- Domain
- api, cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100