Unable to run codex due to Error loading configuration: No such file or directory (os error 2)
Resolved 💬 15 comments Opened Aug 30, 2025 by ajasingh Closed Nov 21, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
codex-cli 0.27.0
Which model were you using?
gpt-5
What platform is your computer?
Darwin 24.6.0 arm64 arm
What steps can reproduce the bug?
I have install codex using npm i -g @openai/codex and when i try to run Error loading configuration: No such file or directory (os error 2) can u guide how to fix this
What is the expected behavior?
_No response_
What do you see instead?
_No response_
Additional information
_No response_
15 Comments
+1
maybe u coudl find a file which named .codex in your userpath(~/.codex) , delete it and mkdir ~/.codex ; then codex can be run
+1
+1
+1
I was having this issue when trying to wire this up with a github action, this is how I've fixed it:
This was originally inspired by: https://cookbook.openai.com/examples/codex/jira-github
By creating a blank config.toml in the codex home directory (e.g.
~/.codex), this seemed to fix the error I was getting.For me it's heisenbug, it can sometimes appear out of nowhere and then vanish. Usually restarting codex cli helps. Usually codex have been running for a while, and usually happens in multi-turn tasks.
I'm on 0.47.0, currently latest version and in WSL2
<img width="575" height="222" alt="Image" src="https://github.com/user-attachments/assets/5881111f-87b1-4f28-b4ce-2781deadcaa6" />
<img width="842" height="169" alt="Image" src="https://github.com/user-attachments/assets/ecea6ae6-ea7c-4c49-ac68-a87e1f1d9540" />
Currently codex itself found a fix using
cd ... && <command><img width="912" height="297" alt="Image" src="https://github.com/user-attachments/assets/e763c1d9-4fb1-4f0b-a0d1-d186751879ba" />
Maybe something with cwd is messing with sandboxing.
+1
I found the solution: remove the CODEX_HOME env variable will solve it
and getting
in the vscode extension
Ok, turns out somehow CODEX_HOME in both WSL and Windows got set to a .codex in a project directory instead of my home directory somehow. Anyway, I was able to fix by just removing CODEX_HOME from path in both WSL and Windows.
WSL:
unset CODEX_HOMEWindows Powershell:
Remove-Item Env:CODEX_HOMEAs noted above, if you're seeing this error with recent versions of the CLI or extension, it's probably because you have a
CODEX_HOMEenvironment variable defined that is an invalid path.Solution for me was to delete the
.tomlfile at the root directory~/.codex/and re-running codex in the CLI for it to automatically re-generate that file.Unfortunately, none of the tips above worked for me or applied to my setup. Codex worked well for months, and then one day, it suddenly stopped with the error above.
I fixed it by using the Codex (Mac) app, signed out, then signed back in. It seems that it reauthenticated with OpenAI. Afterward, it worked fine again, in the app and the CLI.
Just delete the delete ~/.codex file