Codex CLI crashes with Error: spawn rg ENOENT when ripgrep isn’t installed
Resolved 💬 6 comments Opened Apr 16, 2025 by bjmoonn Closed Apr 16, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator)
responded on this thread — see the highlighted reply below.
When running codex without having rg (ripgrep) on the PATH, the CLI throws an unhandled “spawn rg ENOENT” error and exits.
Ensure ripgrep is not installed or not in your $PATH.
node:events:502
throw er; // Unhandled 'error' event
^
Error: spawn rg ENOENT
at ChildProcess._handle.onexit (…)
…
code: 'ENOENT',
syscall: 'spawn rg',
path: 'rg',
spawnargs: [ '--files' ]
}
The CLI should detect if rg is unavailable and either:
- Fall back to a bundled file-walk implementation, or
- Emit a user-friendly error asking to install ripgrep (e.g. “Please install ripgrep (https://github.com/BurntSushi/ripgrep) and ensure rg is on your PATH.”)
6 Comments
After installing ripgrep, still running into an issue when it tries to execute the command.
Maybe related to having pipe in the command?
Repo command:
codex "how many files in this codebase?" -m gpt-4oPossibly related to https://github.com/openai/codex/issues/45
Issue of hard requirement on rg should be fixed in
https://github.com/openai/codex/pull/50
Running into same issue. Even after installing
rgit keeps failing with same error.Works when using
Same problem on Windows...
We removed the
rgrequirement in https://github.com/openai/codex/pull/50 and re-released.