codex icon indicating copy to clipboard operation
codex copied to clipboard

Unable to run codex due to Error loading configuration: No such file or directory (os error 2)

Open ajasingh opened this issue 1 year ago • 15 comments

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

ajasingh avatar Aug 30 '25 05:08 ajasingh

+1

taosu0216 avatar Sep 02 '25 06:09 taosu0216

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

taosu0216 avatar Sep 02 '25 06:09 taosu0216

+1

YuweiXiao avatar Sep 12 '25 03:09 YuweiXiao

+1

micdream4 avatar Sep 16 '25 13:09 micdream4

+1

matjai avatar Sep 28 '25 10:09 matjai

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.

scottjs avatar Oct 08 '25 15:10 scottjs

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

Image Image

Currently codex itself found a fix using cd ... && <command>

Image

Maybe something with cwd is messing with sandboxing.

kvcop avatar Oct 24 '25 07:10 kvcop

+1

Th1nhNg0 avatar Nov 06 '25 18:11 Th1nhNg0

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

Th1nhNg0 avatar Nov 06 '25 18:11 Th1nhNg0

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 avatar Nov 10 '25 00:11 chriswingler

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

chriswingler avatar Nov 10 '25 00:11 chriswingler

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.

etraut-openai avatar Nov 21 '25 06:11 etraut-openai

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.

santidevhmo avatar Jan 26 '26 18:01 santidevhmo

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.

andreascful avatar Mar 11 '26 09:03 andreascful

Just delete the delete ~/.codex file

ricoNext avatar Mar 13 '26 02:03 ricoNext