Don't show command failure when ripgrep returns no matches
What version of Codex is running?
0.73.0
What subscription do you have?
PRO
Which model were you using?
gpt-5.2 - (reasoning high, summaries auto)
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What issue are you seeing?
When running rg (ripgrep) commands, codex-cli marks the command with a failure indicator (red ball) even though the command executed correctly and simply found no matches. Ripgrep returns exit code 1 for “no matches”, which is expected behavior, but codex-cli appears to treat any non-zero exit code as a failure. This creates a misleading UX (“rg is broken”) and seems to push the agent into slower fallback strategies (e.g., scanning files with Get-Content) instead of refining search queries.
What steps can reproduce the bug?
- On Windows, open PowerShell 7.x.
cdinto a repo containing a file that does not contain the searched term.- Run:
``powershell``
rg -n "Family" data\sql\base\db_world\spell_dbc.sql | Select-Object -First 60
- Observe codex-cli marking the command as failed (red ball).
- In the same shell, run:
``powershell``
$LASTEXITCODE
Output is 1 (no matches).
- Also verify there is no output even without the pipeline:
``powershell``
rg -n "Family" data\sql\base\db_world\spell_dbc.sql -n -C 2 --max-count 20
(No output, consistent with “no matches”, not an execution error.)
What is the expected behavior?
- codex-cli should not label ripgrep exit code 1 (“no matches”) as a command failure.
- Ideally, codex-cli should surface this state explicitly as something like “No matches found” (neutral state) rather than a red failure icon.
- This would reduce confusion and avoid triggering unnecessary fallbacks / incorrect debugging steps.
Additional information
- Ripgrep uses exit codes:
0 = matches,1 = no matches,2 = error. Treating1as “failure” is technically correct at the process level but misleading in UX. - Potential improvement: special-case common tools (rg/grep) or allow per-command exit code semantics (e.g., treat
1as non-error for rg). - Also: using
Select-Object -First Nin a pipeline can sometimes create “broken pipe” edge cases with native executables, but in this repro the lack of output plus--max-counttest strongly indicates genuine “no matches”.
ripgrep 15.1.0 (rev af60c2de9d)
features:+pcre2
simd(compile):+SSE2,-SSSE3,-AVX2
simd(runtime):+SSE2,+SSSE3,+AVX2
PCRE2 10.45 is available (JIT is available)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗