Skip to content

Bug: --list-sessions ignores saved /auth state and strictly requires GEMINI_API_KEY env var #26906

@sangalo20

Description

@sangalo20

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: b0c7a17

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.

Metadata

Metadata

Assignees

Labels

area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualityarea/coreIssues related to User Interface, OS Support, Core Functionalityarea/securityIssues related to securityeffort/small1 day or less: trivial logic, UI adjustments, docskind/bugpriority/p2Important but can be addressed in a future release.status/bot-triagedstatus/manual-triage

Type

No fields configured for Bug.

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions