Skip to content

Error: ENOENT: no such file or directory, lstat '/Users/{$profile}/.pyenv' #330

Closed

Description

@ecsplendid

What version of Codex is running?

v0.1.2504172351

Which model were you using?

o4-mini

What platform is your computer?

Darwin 24.2.0 arm64 arm

What steps can reproduce the bug?

Doing anything, it crashes after thinking for a while and after applying changes

What is the expected behavior?

It should work

What do you see instead?

node:fs:2788
      const stats = binding.lstat(base, true, undefined, true /* throwIfNoEntry */);
                            ^

Error: ENOENT: no such file or directory, lstat '/Users/timscarfe/.pyenv'
    at realpathSync (node:fs:2788:29)
    at file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:368:3516
    at Array.map (<anonymous>)
    at Vee (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:368:3425)
    at Wee (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:441:254)
    at sN (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:441:5715)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async ate (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:441:4898)
    at async T0.handleFunctionCall (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:465:4041)
    at async T0.processEventsWithoutStreaming (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:466:5829) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/Users/timscarfe/.pyenv'
}

Node.js v23.5.0

https://chatgpt.com/share/68024a22-0c64-8011-9a7e-b92963159c92

What actually happened

1. When the Codex CLI boots it tries to discover every Python interpreter on your machine.
2. One probe is a hard‑coded call to fs.lstatSync('~/.pyenv', /* throwIfNoEntry = */ true) that lives in the bundled dist/cli.js (around line 368).
3. Because you don’t have pyenv installed (or the directory has a different name), fs.lstatSync throws ENOENT (“file or directory not found”).
4. That exception is not caught inside Codex CLI, so Node bubbles it up and the whole process dies before the TTY prompt is even initialised. That’s the stack‑trace you’re seeing.
OpenAI Help Center
Node.js — Run JavaScript Everywhere

This isn’t a Node‑23 problem, and it isn’t your shell. It’s simply a missing guard‑clause in Codex CLI’s pyenv‑detection code.

Additional information

No response

Activity

  1. added
    bug
    on Apr 18, 2025
  2. jasneetsingh6114 commented on Apr 18, 2025

    @jasneetsingh6114

    Hey can I work on this issue ?

  3. The-Obstacle-Is-The-Way commented on Apr 18, 2025

    @The-Obstacle-Is-The-Way

    Same, just got this issue:

    node:fs:2788
    const stats = binding.lstat(base, true, undefined, true /* throwIfNoEntry */);
    ^

    Error: ENOENT: no such file or directory, lstat '/Users/ray/.pyenv'
    at realpathSync (node:fs:2788:29)
    at file:///Users/ray/Desktop/GITHUB/codex/codex-cli/dist/cli.js:368:3516
    at Array.map ()
    at Vee (file:///Users/ray/Desktop/GITHUB/codex/codex-cli/dist/cli.js:368:3425)
    at Wee (file:///Users/ray/Desktop/GITHUB/codex/codex-cli/dist/cli.js:441:254)
    at sN (file:///Users/ray/Desktop/GITHUB/codex/codex-cli/dist/cli.js:441:5715)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async ate (file:///Users/ray/Desktop/GITHUB/codex/codex-cli/dist/cli.js:441:4898)
    at async T0.handleFunctionCall (file:///Users/ray/Desktop/GITHUB/codex/codex-cli/dist/cli.js:465:4041)
    at async T0.processEventsWithoutStreaming (file:///Users/ray/Desktop/GITHUB/codex/codex-cli/dist/cli.js:466:5829) {
    errno: -2,
    code: 'ENOENT',
    syscall: 'lstat',
    path: '/Users/ray/.pyenv'
    }

    Node.js v23.10.0

    Codex is now unuseable

  4. pheuter commented on Apr 18, 2025

    @pheuter

    Not a fix, but you can revert back to the previous version as a workaround: npm i -g @openai/[email protected]

  5. The-Obstacle-Is-The-Way commented on Apr 18, 2025

    @The-Obstacle-Is-The-Way

    Not a fix, but you can revert back to the previous version as a workaround: npm i -g @openai/[email protected]

    Instead it looks like I installed Codex via homebrew, and all that was needed was the .pyenv in my root, and now works properly:

    "What We Did (Simple Steps)
    Created the missing .pyenv directory that Codex was looking for
    Restored the code to the latest version
    Successfully launched Codex with the newest version (v0.1.2504180837)
    Why This Fixed It
    The Codex CLI is checking for Python environments across your system. Creating that empty directory fixed the bug because now when Codex looks for that directory, it finds it and doesn't crash.

    Technical Note
    This is an example of proper error handling - the application should have checked if that directory existed before trying to access it. This simple directory creation fixed what would have been a one-line code fix in the application itself.

    You can now use the Codex CLI as intended with the latest version. The empty .pyenv directory won't affect anything on your system - it's just there so the application doesn't crash when looking for it."

    If this didn't work I was going to use the roll back

  6. gianpaj commented on Apr 18, 2025

    @gianpaj

    I got the same error

    node:fs:2705
          const stats = binding.lstat(base, true, undefined, true /* throwIfNoEntry */);
                                ^
    
    Error: ENOENT: no such file or directory, lstat '/Users/gianpaj/.pyenv'
        at realpathSync (node:fs:2705:29)
        at file:///Users/gianpaj/.asdf/installs/nodejs/22.9.0/lib/node_modules/@openai/codex/dist/cli.js:368:3516
        at Array.map (<anonymous>)
        at Vee (file:///Users/gianpaj/.asdf/installs/nodejs/22.9.0/lib/node_modules/@openai/codex/dist/cli.js:368:3425)
        at Wee (file:///Users/gianpaj/.asdf/installs/nodejs/22.9.0/lib/node_modules/@openai/codex/dist/cli.js:441:254)
        at sN (file:///Users/gianpaj/.asdf/installs/nodejs/22.9.0/lib/node_modules/@openai/codex/dist/cli.js:441:5715)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async ate (file:///Users/gianpaj/.asdf/installs/nodejs/22.9.0/lib/node_modules/@openai/codex/dist/cli.js:441:4898)
        at async T0.handleFunctionCall (file:///Users/gianpaj/.asdf/installs/nodejs/22.9.0/lib/node_modules/@openai/codex/dist/cli.js:465:4041)
        at async T0.processEventsWithoutStreaming (file:///Users/gianpaj/.asdf/installs/nodejs/22.9.0/lib/node_modules/@openai/codex/dist/cli.js:466:5829) {
      errno: -2,
      code: 'ENOENT',
      syscall: 'lstat',
      path: '/Users/gianpaj/.pyenv'
    }
    
    ╭──────────────────────────────────────────────────────────────╮
    │ ● OpenAI Codex (research preview) v0.1.2504172351            │
    ╰──────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────╮
    │ localhost session: 2b750a717dca411aa3788cf9c4323901          │
    │ ↳ workdir: ~/tmp/HowToCook                                   │
    │ ↳ model: o4-mini                                             │
    │ ↳ approval: full-auto                                        │
    ╰──────────────────────────────────────────────────────────────╯
    
  7. gianpaj commented on Apr 18, 2025

    @gianpaj

    It looks like this issue was introduced in the last release with this PR #275 by @jonchurch

  8. steipete commented on Apr 18, 2025

    @steipete

    I run into the same issue, it triggers quite fast.

  9. jonchurch commented on Apr 18, 2025

    @jonchurch
    Contributor

    Ah yes, this makes sense.

    realpath is likely throwing here, due to the path not existing, I did not consider that possibility

  10. jonchurch commented on Apr 18, 2025

    @jonchurch
    Contributor

    How are you reproducing this? full auto mode or interactive?

    I do not have that dir on my system, but have never seen this error

  11. The-Obstacle-Is-The-Way commented on Apr 18, 2025

    @The-Obstacle-Is-The-Way

    Full auto. Windsurf and API was able to fix it locally via my comment above if that helps.

  12. jonchurch commented on Apr 18, 2025

    @jonchurch
    Contributor

    Revert PR #370
    cc @fouad-openai @tibo-openai

    Sorry for the breakage folks, you can either mkdir -p ~/.pyenv to unblock

    or npm i -g @openai/[email protected] to roll yourself back

    I'll open a PR that does the same thing but will handle exceptions for non existant writeable roots, falling back to their non resolved paths for consideration

  13. steipete commented on Apr 18, 2025

    @steipete

    To repro, try full auto mode and ask it to “take a deep look and update the readme”

  14. binbandit commented on Apr 21, 2025

    @binbandit
    Contributor

    If we can get #172 merged, it will address this issue

  15. codex-maintainers commented on Aug 7, 2025

    @codex-maintainers

    Thanks for the feedback! Please try again on the latest version of Codex CLI. If the issue persists, let us know.

  16. binbandit commented on Aug 11, 2025

    @binbandit
    Contributor

    This issue still persists in the codex-rs version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions