Skip to content

Gemini CLI for Vertex AI Authentication #267

Description

@ryuchan-debug

Description of the bug:

CLI Version:
0.11.3

Operating System:
Windows

Objective:
Authenticate Gemini CLI with Google Cloud Vertex AI using a service account.

Symptoms:

  • The gemini -d "Hello" command consistently fails to authenticate via Vertex AI.
  • The debug output does not contain the expected Authenticated via 'vertex-ai' message.
  • The debug output always contains the message Loaded cached credentials., even when all known credential caches are disabled.

Troubleshooting Steps Performed:
We have exhaustively checked and verified the following configurations and steps:

  1. Environment Variables: All required variables are correctly set:
    • GOOGLE_GENAI_USE_VERTEXAI=true
    • GOOGLE_CLOUD_PROJECT
    • GOOGLE_CLOUD_LOCATION
    • GOOGLE_APPLICATION_CREDENTIALS
  2. Credentials File:
    • The path points to a valid service account JSON key.
    • Tested with a direct, physical file path (e.g., C:\keys\key.json) to rule out symbolic link issues.
    • Generated a new service account key and tested with it.
  3. GCP Project Settings:
    • Vertex AI API is enabled.
    • A billing account is linked to the project.
    • The service account has the "Vertex AI User" role.
  4. Credential Cache:
    • The standard ADC cache file (%APPDATA%\google-auth\hs_credentials.json) does not exist.
    • The gcloud config directory (%APPDATA%\gcloud) was temporarily renamed to disable it, but this had no effect on the outcome.

Conclusion:
Despite all correct configurations, the Gemini CLI appears to be incorrectly prioritizing an unknown cached credential source and ignoring the GOOGLE_APPLICATION_CREDENTIALS environment variable. This is likely a bug in the credential loading priority chain within the CLI on Windows.

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions