env variable not found in windows terminal
What version of Codex is running?
0.1.2504251709
Which model were you using?
gemini-2.0-flash
What platform is your computer?
Microsoft Windows NT 10.0.26100.0 x64
What steps can reproduce the bug?
I am installing Codex using the npm library, and I want to set up the environment variable for the API key.
In my PowerShell, I run the following command:
setx GEMINI_API_KEY "your_api_key"
This saves the API key in the Windows global environment variables.
I can verify that it was saved correctly by running:
node -e "console.log(process.env.GEMINI_API_KEY)"
This successfully prints my API key.
When I run codex in the terminal, I still get the following error:
` Missing Gemini API key.
Set the environment variable GEMINI_API_KEY and re-run this command.
You can create a GEMINI_API_KEY in the Google AI Studio.
`
Even though the environment variable is set, the error persists.
I also tried setting the environment variable for the current session using:$env:GEMINI_API_KEY = "your_api_key"
But the problem remains — Codex still does not recognize the API key.
Additionally, I modified the .codex config file located at:C:\Users\<username>\.codex
In the config file, I manually added the envKey under the Gemini section with my API key.
However, even after these changes, I am still facing the same issue.
What is the expected behavior?
_No response_
What do you see instead?
Additional information
In windows os how the program see the env variable data. And as I know that when I save the env file in windwos it save on the enviromant variable that you can see by searching the Edit Enviroment Variable and then you see a popup like this
and then in the inside the enviroment variable you have the data. Am I right?
4 Comments
Requirements:
Operating systems macOS 12+, Ubuntu 20.04+/Debian 10+, or Windows 11 via WSL2
@Eg-M but in I run this on my powershell. But after restart my pc it's not wroking
Going to close this because the project currently doesn't support windows without using WSL2, please use WSL2.
@tibo-openai I am facing some wired problem in codex I am in windows machine and I am setting the GEMINI_API_KEY in my enviroment variable and I am so modify the config file in the .codex file in my user root directory. Now codex is install by npm package manager in globally when I install this globally then it not working then it says that missing api key but after uninstalling the codex library from global that is present in Roaming/npm it run perfectly I share a video see this
https://github.com/user-attachments/assets/a3d74461-3654-4f56-85ea-bcf1401092da
If you tell the package is hidden then is tell you I allready enable hidden file. Now tell me even the package is not install then how this is working?