codex crash

Resolved 💬 13 comments Opened Apr 16, 2025 by cuacurie Closed Apr 16, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator) responded on this thread — see the highlighted reply below.

Asked to change the code in a hello world file. everytime it crashes.

node:events:495
throw er; // Unhandled 'error' event
^

Error: spawn rg ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:284:19)
at onErrorNT (node:internal/child_process:477:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:290:12)
at onErrorNT (node:internal/child_process:477:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn rg',
path: 'rg',
spawnargs: [ '--json-path', '.text', '--json-seq' ]
}

Node.js v18.19.0

View original on GitHub ↗

13 Comments

rgregg · 1 year ago

I'm getting this as well - but on Node.js v23.9.0 and I have ripgrep installed and in my path on macOS 15.4. I can't seem to get it to anything because it wants to search the code using rg and fails every time.

node:events:485
      throw er; // Unhandled 'error' event
      ^

Error: spawn rg  ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn rg ',
  path: 'rg ',
  spawnargs: [ 'openai' ]
}

Node.js v23.9.0
ghost · 1 year ago

Same error. On v 23.5.0

den-run-ai · 1 year ago

same here with rg, which is in path:


node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: spawn rg --files ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn rg --files',
  path: 'rg --files',
  spawnargs: []
}

Node.js v20.9.0
den-run-ai · 1 year ago

I figured out the problem. This issue most likely only happens with gpt-4o, once I switched to o4-mini-2025-04-16, then the problem is resolved!

cuacurie · 1 year ago
I figured out the problem. This issue most likely only happens with gpt-4o, once I switched to o4-mini-2025-04-16, then the problem is resolved!

I was using that same model.

den-run-ai · 1 year ago

@cuacurie i also restarted the terminal after brew install ripgrep

DeadmanLabs · 1 year ago

OS: WSL Ubuntu
Node Version: 18.20.6
Tested Models: gpt-4o, o4-mini-2025-04-16

same issues

ghost · 1 year ago

Confirmed. brew install ripgrep then restart terminal

tibo-openai collaborator · 1 year ago

Removed rg as a hard req in https://github.com/openai/codex/pull/50

afiodorov · 1 year ago

Seems to just die when tries to run a non-existing command:


    command.stdout (code: 0, duration: 0.1s)

    fastapi>=0.95.0
    uvicorn>=0.21.1
    httpx>=0.24.0
    mcp[cli]>=0.5.0
    ... (2 more lines)

    thinking for 40s

    thinking for 41s

    command

    $ mcp --help
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│( ●    )  Thinking                                                                                                                                                                                                                                                          │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  send q or ctrl+c to exit | send "/clear" to reset | send "/help" for commands | press enter to send

node:events:485
      throw er; // Unhandled 'error' event
      ^

Error: spawn mcp ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn mcp',
  path: 'mcp',
  spawnargs: [ '--help' ]
}

Node.js v23.10.0
➜  damn-vulnerable-MCP-server git:(main) mcp
zsh: command not found: mcp
afiodorov · 1 year ago

easy to replicate:

user
run command mcp

    thinking for 5s

    command

    $ mcp

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│Shell Command                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                                            │
│$ mcp                                                                                                                                                                                                                                                                       │
│                                                                                                                                                                                                                                                                            │
│Allow command?                                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                                            │
│    Yes (y)                                                                                                                                                                                                                                                                 │
│  ❯ Yes, always approve this exact command for this session (a) ✔                                                                                                                                                                                                           │
│    Edit or give feedback (e)                                                                                                                                                                                                                                               │
│    No, and keep going (n)                                                                                                                                                                                                                                                  │
│    No, and stop for now (esc)                                                                                                                                                                                                                                              │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
node:events:485
      throw er; // Unhandled 'error' event
      ^

Error: spawn mcp ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn mcp',
  path: 'mcp',
  spawnargs: []
}

Node.js v23.10.0
afiodorov · 1 year ago

Fixed for myself in https://github.com/openai/codex/pull/119 - although a global try catch would be nice to stop it from crashing...

tibo-openai collaborator · 1 year ago