The Problem
When running gemini-cli from within a project that has its own .env file (e.g., a Python project using python-dotenv), the CLI attempts to load that project's .env file. This can cause authentication failures if the project's .env file does not contain the GEMINI_API_KEY or other necessary environment variables for the Gemini CLI.
This behavior forces users to either:
- Add their Gemini API key to every project's
.env file, which is not ideal for security or convenience.
- Temporarily rename or move the project's
.env file, which is disruptive to the project's workflow.
Proposed Solution
Provide a mechanism to force the Gemini CLI to ignore the local project's .env file and instead use the global ~/.gemini/.env file.
This could be implemented as:
- A command-line flag:
- A setting in
~/.gemini/settings.json:
{
"ignoreLocalEnv": true
}
Why is this needed?
This feature would improve the user experience by:
- Preventing conflicts: It would prevent conflicts between the Gemini CLI's environment variables and the project's environment variables.
- Improving security: It would avoid the need to store the Gemini API key in multiple project-specific
.env files.
- Increasing convenience: It would allow users to run the Gemini CLI from any project without having to worry about
.env file conflicts.
The Problem
When running
gemini-clifrom within a project that has its own.envfile (e.g., a Python project usingpython-dotenv), the CLI attempts to load that project's.envfile. This can cause authentication failures if the project's.envfile does not contain theGEMINI_API_KEYor other necessary environment variables for the Gemini CLI.This behavior forces users to either:
.envfile, which is not ideal for security or convenience..envfile, which is disruptive to the project's workflow.Proposed Solution
Provide a mechanism to force the Gemini CLI to ignore the local project's
.envfile and instead use the global~/.gemini/.envfile.This could be implemented as:
~/.gemini/settings.json:{ "ignoreLocalEnv": true }Why is this needed?
This feature would improve the user experience by:
.envfiles..envfile conflicts.