Description
🐛 Problem
When running Gemini CLI, some users encounter the following error on login:
Failed to login. Message: This account requires setting the GOOGLE_CLOUD_PROJECT env var.
See https://goo.gle/gemini-cli-auth-docs#workspace-gca
According to the Gemini CLI Authentication Docs, this error should only occur in specific cases, but I am seeing this even though none of those cases apply. I only have personal accounts.
✅ Workaround
The issue can be resolved by explicitly setting GOOGLE_CLOUD_PROJECT in a .env file located at:
- Windows:
%USERPROFILE%\.gemini\
- Linux/macOS:
~/.gemini/
Example:
GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID_HERE
After doing so, Gemini CLI starts and works fine. ✅
The same fix also applies for Kilo Code > Settings > Providers > API Provider > Gemini CLI. ✅
🚨 Issue with Kilo Code
However, when Kilo Code > Settings > Providers > OAuth Credentials Path (optional) > "YOUR_CUSTOM_PATH_HERE\oauth_creds.json" is configured for API Provider Gemini CLI, Kilo Code disregards the .env file located next to the oauth_creds.json file. In chat, this leads to a Gemini CLI API error ❌:
{
"error": {
"code": 403,
"message": "Permission denied on resource project default.",
"errors": [
{
"message": "Permission denied on resource project default.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CONSUMER_INVALID",
"domain": "googleapis.com",
"metadata": {
"containerInfo": "default",
"service": "cloudaicompanion.googleapis.com",
"consumer": "projects/default"
}
},
{
"@type": "type.googleapis.com/google.rpc.LocalizedMessage",
"locale": "en-US",
"message": "Permission denied on resource project default."
},
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developers console",
"url": "https://console.developers.google.com/"
}
]
}
]
}
}
🎯 Expected Behavior
- Each profile change (chat mode) or path change (settings) for Gemini CLI should trigger a reload of the
.env file that resides alongside the selected oauth_creds.json.
🔄 Suggested Fix / Feature Request
- Update the integration of Gemini CLI so that the
.env file is dynamically read/reloaded whenever a different Gemini CLI profile is selected.
- Ensure that
GOOGLE_CLOUD_PROJECT is consistently applied from the .env file next to the active oauth_creds.json, not just from the one originally loaded at launch.
🪜 Reproduce
To reproduce cleanly, you must ensure there’s no “cross-contamination” from the default .gemini folder loading an existing .env file during Kilo Code setup.
- Close VS Code.
- Rename existing
~/.gemini folder.
- Create a
.env file inside it; it contains GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID_HERE.
- Start VS Code and set up the Kilo Code provider Gemini CLI with the OAuth Credentials Path pointing to your
oauth_creds.json.
Of course, for these steps to be relevant, your account must also be one of those flagged as requiring the GOOGLE_CLOUD_PROJECT setting, as detailed in the Gemini CLI authentication docs.
📌 Summary
- Problem: Gemini CLI (vanilla & Kilo Code) requires
GOOGLE_CLOUD_PROJECT env var, even for personal accounts where it shouldn't be needed.
- Workaround: Manually creating a
.env file with GOOGLE_CLOUD_PROJECT in ~/.gemini/ fixes the issue for the standard CLI and for Kilo Code's default setup.
- Kilo Code Issue: Kilo Code ignores the
.env file when a custom path for oauth_creds.json is used, causing API errors.
- Expected Fix: Kilo Code should dynamically load the
.env file that is located next to the currently active oauth_creds.json upon profile or path changes.
💻 Environment
Related to
#947
#1153
#1199
#1454
cline/cline#4526
google-gemini/gemini-cli#1432
google-gemini/gemini-cli#3001
Description
🐛 Problem
When running Gemini CLI, some users encounter the following error on login:
According to the Gemini CLI Authentication Docs, this error should only occur in specific cases, but I am seeing this even though none of those cases apply. I only have personal accounts.
✅ Workaround
The issue can be resolved by explicitly setting
GOOGLE_CLOUD_PROJECTin a.envfile located at:%USERPROFILE%\.gemini\~/.gemini/Example:
After doing so, Gemini CLI starts and works fine. ✅
The same fix also applies for
Kilo Code > Settings > Providers > API Provider > Gemini CLI. ✅🚨 Issue with Kilo Code
However, when
Kilo Code > Settings > Providers > OAuth Credentials Path (optional) > "YOUR_CUSTOM_PATH_HERE\oauth_creds.json"is configured for API Provider Gemini CLI, Kilo Code disregards the.envfile located next to theoauth_creds.jsonfile. In chat, this leads to a Gemini CLI API error ❌:{ "error": { "code": 403, "message": "Permission denied on resource project default.", "errors": [ { "message": "Permission denied on resource project default.", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "CONSUMER_INVALID", "domain": "googleapis.com", "metadata": { "containerInfo": "default", "service": "cloudaicompanion.googleapis.com", "consumer": "projects/default" } }, { "@type": "type.googleapis.com/google.rpc.LocalizedMessage", "locale": "en-US", "message": "Permission denied on resource project default." }, { "@type": "type.googleapis.com/google.rpc.Help", "links": [ { "description": "Google developers console", "url": "https://console.developers.google.com/" } ] } ] } }🎯 Expected Behavior
.envfile that resides alongside the selectedoauth_creds.json.🔄 Suggested Fix / Feature Request
.envfile is dynamically read/reloaded whenever a different Gemini CLI profile is selected.GOOGLE_CLOUD_PROJECTis consistently applied from the.envfile next to the activeoauth_creds.json, not just from the one originally loaded at launch.🪜 Reproduce
To reproduce cleanly, you must ensure there’s no “cross-contamination” from the default
.geminifolder loading an existing.envfile during Kilo Code setup.~/.geminifolder..envfile inside it; it containsGOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID_HERE.oauth_creds.json.Of course, for these steps to be relevant, your account must also be one of those flagged as requiring the GOOGLE_CLOUD_PROJECT setting, as detailed in the Gemini CLI authentication docs.
📌 Summary
GOOGLE_CLOUD_PROJECTenv var, even for personal accounts where it shouldn't be needed..envfile withGOOGLE_CLOUD_PROJECTin~/.gemini/fixes the issue for the standard CLI and for Kilo Code's default setup..envfile when a custom path foroauth_creds.jsonis used, causing API errors..envfile that is located next to the currently activeoauth_creds.jsonupon profile or path changes.💻 Environment
Related to
#947
#1153
#1199
#1454
cline/cline#4526
google-gemini/gemini-cli#1432
google-gemini/gemini-cli#3001