.zshrc file includes GEMINI_API_KEY but gemini cli claims no API key on MacOS
What happened?
I have checked the zshrc file in separate editors and windows, verified GEMINI_API_KEY is correctly set with current API key i use with other Gemini integrations with no problems,
obviously sourced ~/.zshrc tried new terminal windows exit terminal completely and restart, etc.
ALWAYS immediately says "No API Key found! Make sure GEMINI_API_KEY= is in .env"
What did you expect to happen?
This is a new behavior, as Gemini Cli WAS working yesterday, with my API key in the zshrc file, it was able to recognize it and started successfully with no auth or api issues.
macOS latest sequoia 15.5 MB pro m2 max 32g 1tb 2023
default zsh shell from home/User/<account_name>/
every other PATH or zshrc file contents and custom system variables for scripting defined in rc file works. like i said, this didnt happen before. Now it always happens, current API key used in vscode extension, google AI studio, etc.
Client information
$ gemini /about
CLI Version 0.1.5
Git Commit bf873a1
Model gemini-2.5-pro
Sandbox no sandbox
OS darwin
Login information
API in gemini ai studio
Anything else we need to know?
No response
Just as a sanity check, at the place where you run gemini can you echo $GEMINI_API_KEY and also check that there is no empty GEMINI_API_KEY= line in .env? Don't paste the key here obvs but just check that it's present.
And can you share any settings.json files that would be sourced? And the output of gemini --version. Since you can't run /about I'm trying to figure out if you have a sandbox enabled, plus other environmental factors.
well, i guess i fixed it?. yes i had done the above and was seeing GEMINI_API_KEY, like i said i have verified its there. but gemini cli wouldnt recognize the .zshrc file so i created a .env with just GEMINI_API_KEY.. but i dont know why it wouldnt recognize or read .zshrc still
@dead-developers I put my GEMINI_API_KEY in bashrc on Ubuntu as I access Ubuntu just through CLI and it worked
echo 'export GEMINI_API_KEY="your-api-key-here"' >> ~/.bashrc source ~/.bashrc
On mac I always login through google or used it in env file as I have clones the repo. Maybe its just some bug on your side and not problem with Gemini but lmk if it still persists I can try to replicate it on my Macbook :) I use zsh
@dead-developers 👋 Thanks for reporting this. Closing as it sounds like you have resolved the issue.
Please remember to source ~/.zshrc after you update the key.