openai / openai/codex

Windows/PowerShell: Codex CLI repeatedly generates invalid ripgrep glob arguments (os error 123)

Open
#45,685 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI model-behavior tool-calls windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

OpenAI Codex (v0.154.0)

What subscription do you have?

pro 20x (expired) ->pro 5X

Which model were you using?

gpt-6-astra

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

PowerShell

Codex doctor report
not available
What issue are you seeing?

When running Codex CLI with PowerShell on Windows, Codex repeatedly generates ripgrep commands like:

rg 'pattern' *.md

This fails with os error 123.

The following form works in the same environment:

rg -g '*.md' 'pattern' .

The issue is not just a single failed search: Codex keeps generating the unsupported command form during normal use. This creates avoidable failed tool calls and recovery work, wasting time and tokens on a predictable shell-specific problem.

What steps can reproduce the bug?

The following steps isolate the command-level failure without depending on Codex generating the same command in a new session.

In an empty test directory, using PowerShell on Windows with ripgrep installed, create a Markdown file:

Set-Content -LiteralPath .\sample.md -Value 'pattern' -Encoding utf8

Run the command form generated by Codex:

rg 'pattern' *.md

It fails with os error 123.

Then run:

rg -g '*.md' 'pattern' .

The search succeeds and finds the matching text.

What is the expected behavior?

Codex should generate ripgrep commands that are valid for the active shell.

For recursive searches limited to Markdown files in PowerShell, it should use:

rg -g '*.md' 'pattern' .

If the intended scope is only the current directory, it should use:

rg --max-depth 1 -g '*.md' 'pattern' .

Codex should avoid repeatedly generating the unsupported positional-glob form.

Additional information

PowerShell does not perform Bash-style filename glob expansion for native executables such as ripgrep. In the failing command, *.md is passed as a literal path argument rather than expanded into matching filenames.

Using -g '*.md' lets ripgrep interpret the glob itself, while . supplies an actual search directory. Merely adding quotes around the positional *.md argument would not address this distinction.

Please consider strengthening the Windows/PowerShell-specific guidance used by the agent:

  • Prefer ripgrep's -g / --glob option with an explicit search path instead of relying on shell glob expansion.
  • Preserve the intended search depth rather than silently turning a current-directory search into a recursive search.
  • Add a PowerShell command-generation evaluation or regression test covering this case.

This report concerns Codex's shell-aware command generation, not a request to change PowerShell or ripgrep behavior. Better default guidance could prevent these unnecessary failures and reduce wasted time and tokens.

I was checking and testing this today, and I forgot to renew my Pro 20X subscription. When I went to pay, I found that new subscriptions for the 20X plan were no longer available. I resubscribed to the 5X plan instead, but since the weekly usage limit is only one-quarter of the 20X plan's, my remaining allowance is now zero. I am currently unable to perform any tasks. My account is snowyegretshare@gmail.com. https://x.com/aabb0423/status/2099702602384712059?s=20 I was joking when I sent the tip via Twitter, but now I'm seriously hoping for a miracle. Haha.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating Codex CLI's shell-aware command-generation entry point and any existing PowerShell evaluation or regression tests; the issue names no specific files. Reproduce the positional-glob failure on Windows, then add coverage for the explicit ripgrep glob form while preserving the intended search depth. Done means the test passes and generated commands avoid the unsupported form.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
cli, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.