The CLI doesn't seem to read ~/.env for the GEMINI_API_KEY
Description of the bug:
Even after adding GEMINI_API_KEY to my ~/.env file, the CLI complains the API key is not set.
Actual vs expected behavior:
$ gemini-code
GEMINI_API_KEY is not set. See https://ai.google.dev/gemini-api/docs/api-key to obtain one. Please set it in your .env file or as an environment variable.
$ cat > ~/.env
GEMINI_API_KEY=....
$ gemini-code
GEMINI_API_KEY is not set. See https://ai.google.dev/gemini-api/docs/api-key to obtain one. Please set it in your .env file or as an environment variable.
Any other information you'd like to share?
Defining the API key as environment variable works
$ export GEMINI_API_KEY=...
$ gemini-code
[works!]
Hmmm, that should work. What sort of sandboxing are you running under?
For context, this is the logic to load .env from parent directories.
guessing home (~) is not a parent directory, which happens on cloudtops as /google/src has its own mount; we should still include ~/.env when it is not a parent directory
On Tue, May 13, 2025 at 9:08 AM N. Taylor Mullen @.***> wrote:
NTaylorMullen left a comment (google-gemini/gemini-code#326) https://github.com/google-gemini/gemini-code/issues/326#issuecomment-2877141178
Hmmm, that should work. What sort of sandboxing are you running under?
For context, this https://github.com/google-gemini/gemini-code/blob/61ccd4f33a17e05726537d74b6d5ba578d33cd78/packages/server/src/config/config.ts#L91 is the logic to load .env from parent directories.
— Reply to this email directly, view it on GitHub https://github.com/google-gemini/gemini-code/issues/326#issuecomment-2877141178, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFWNPFVKYDL2PWJ6RBUI2D26IKHRAVCNFSM6AAAAAB5AGXMCCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNZXGE2DCMJXHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
workaround is to copy or symlink ~/.env from an appropriate parent folder
On Tue, May 13, 2025 at 12:36 PM Olcan Sercinoglu @.***> wrote:
guessing home (~) is not a parent directory, which happens on cloudtops as /google/src has its own mount; we should still include ~/.env when it is not a parent directory
On Tue, May 13, 2025 at 9:08 AM N. Taylor Mullen @.***> wrote:
NTaylorMullen left a comment (google-gemini/gemini-code#326) https://github.com/google-gemini/gemini-code/issues/326#issuecomment-2877141178
Hmmm, that should work. What sort of sandboxing are you running under?
For context, this https://github.com/google-gemini/gemini-code/blob/61ccd4f33a17e05726537d74b6d5ba578d33cd78/packages/server/src/config/config.ts#L91 is the logic to load .env from parent directories.
— Reply to this email directly, view it on GitHub https://github.com/google-gemini/gemini-code/issues/326#issuecomment-2877141178, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFWNPFVKYDL2PWJ6RBUI2D26IKHRAVCNFSM6AAAAAB5AGXMCCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNZXGE2DCMJXHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@olcan do you think we should be special casing ~/?
yeah (as mentioned above) i think we should always include ~/.env even if it is not a parent directory. if you agree i can make this change
Ya I agree!
fixed in https://github.com/google-gemini/gemini-code/pull/338
The reported issue with read_file and read_many_files on Windows indicates a failure in the agent's tool execution logic. Given the significantly outdated CLI version (0.1.7) compared to the current release (0.61.0), please verify if this issue persists in the latest version.