gemini-cli - 💡(How to fix) Fix Bug: `--list-sessions` ignores saved `/auth` state and strictly requires `GEMINI_API_KEY` env var [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  1. Poor Error Handling Sequence: The No previous sessions found for this project. message prints prematurely. It checks for files, hits an auth failure, and assumes no files exist rather than waiting to catch and report the auth failure cleanly.

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

What happened?

When running the gemini --list-sessions command, the CLI ignores the internally saved authentication state. If the GEMINI_API_KEY environment variable is not explicitly exported in the current shell, the command crashes.

What did you expect to happen?

The --list-sessions command should use the exact same authentication resolution logic as the main gemini command. It should recognize the saved internal /auth state, authenticate successfully without strictly requiring the environment variable, and correctly list the existing local sessions.

Client information

CLI Version: 0.41.2

Git Commit: b0c7a1722

Model: Auto (Gemini 3)

Sandbox: no sandbox

OS: darwin (macOS)

IDE Client: Antigravity

Login information

API Key

Anything else we need to know?

There appear to be two distinct issues happening simultaneously here:

  1. Inconsistent Auth Loading: The --list-sessions flag seems hardcoded to check only the environment variable or local .env file, completely bypassing the internal config loader that standard commands use.
  2. Poor Error Handling Sequence: The No previous sessions found for this project. message prints prematurely. It checks for files, hits an auth failure, and assumes no files exist rather than waiting to catch and report the auth failure cleanly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING