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_

View original on GitHub ↗

15 Comments

taosu0216 · 10 months ago

+1

taosu0216 · 10 months ago

maybe u coudl find a file which named .codex in your userpath(~/.codex) , delete it and mkdir ~/.codex ; then codex can be run

YuweiXiao · 10 months ago

+1

micdream4 · 10 months ago

+1

matjai · 9 months ago

+1

scottjs · 9 months ago

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.

kvcop · 8 months ago

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.

Th1nhNg0 · 8 months ago

+1

Th1nhNg0 · 8 months ago

I found the solution: remove the CODEX_HOME env variable will solve it

chriswingler · 8 months ago

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

chriswingler · 8 months ago

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

etraut-openai contributor · 8 months ago

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.

santidevhmo · 5 months ago

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.

andreascful · 4 months ago

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.

ricoNext · 4 months ago

Just delete the delete ~/.codex file