Unable to run codex due to Error loading configuration: No such file or directory (os error 2)
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
+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:
- name: Prepare Codex home
run: |
export CODEX_HOME="${{ runner.temp }}/.codex"
echo "CODEX_HOME=$CODEX_HOME" >> $GITHUB_ENV
mkdir -p "$CODEX_HOME"
touch "$CODEX_HOME/config.toml"
- name: Codex login
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
printf '%s' "$OPENAI_API_KEY" | codex login --with-api-key
codex login status
- name: Run Codex CLI
run: |
set -e
codex --full-auto exec -s workspace-write -- <<'PROMPT'
Implement JIRA ticket ${{ inputs.issue_key }}: ${{ inputs.issue_summary }}.
${{ inputs.issue_description }}
Requirements:
- Follow repository conventions.
- Do not modify CI workflows.
- You are running in CI/CD mode.
PROMPT
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
Currently codex itself found a fix using cd ... && <command>
Maybe something with cwd is messing with sandboxing.
+1
I found the solution: remove the CODEX_HOME env variable will solve it
and getting
An error has occurred
Codex crashed with the following error:
Codex process errored: Codex process is not available
Error: error loading config: The filename, directory name, or volume label syntax is incorrect. (os error 123)
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_HOME
Windows Powershell:
Remove-Item Env:CODEX_HOME
As noted above, if you're seeing this error with recent versions of the CLI or extension, it's probably because you have a CODEX_HOME environment variable defined that is an invalid path.
Solution for me was to delete the .toml file 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