Windows PowerShell: Codex should quote paths containing parentheses like Next.js app/(main)
Codex CLI sometimes generates shell commands on Windows PowerShell with unquoted paths that contain parentheses, such as Next.js route group paths:
rg test iPlantMES/apps/web/app/(main)/admin -S
In PowerShell, (main) is not treated as a literal path segment. It is parsed as an expression/command token. On Windows, main resolves to:
C:\Windows\System32\main.cpl
So this can unexpectedly open the Mouse Properties control panel, or split the path incorrectly.
Environment:
- Codex CLI: 0.129.0
- OS: Windows
- Shell: Windows PowerShell 5.1.26100.8115
- Node: v22.14.0
- Project type: Next.js app router with route group folder
(main)
Reproduction:
- In a Windows PowerShell environment, use a project path containing
app/(main)/admin. - Ask Codex to inspect/search files under that path.
- Codex may emit a command like:
rg test iPlantMES/apps/web/app/(main)/admin -S
- PowerShell parses
(main)instead of treating it as a literal path.
Observed:
- The path is split incorrectly.
- In some cases Windows opens Mouse Properties via
main.cpl.
Expected:
Codex should quote or escape paths containing PowerShell metacharacters, for example:
rg test 'iPlantMES/apps/web/app/(main)/admin' -S
or otherwise use safe path passing on Windows PowerShell.
4 Comments
Additional confirmation and workaround:
I confirmed that this is caused by PowerShell parsing the unquoted
(main)segment instead of treating it as a literal path.Test 1: check what
mainresolves to on Windows PowerShell```powershell
Get-Command main
Result:
Application main.cpl C:\WINDOWS\system32\main.cpl
So if PowerShell evaluates main as a command, it can open the Mouse Properties control panel.
Test 2: compare PowerShell token parsing
Unquoted:
rg test iPlantMES/apps/web/app/(main)/admin -S
PowerShell tokenizes it like this:
Generic :: iPlantMES/apps/web/app/
LParen :: (
Identifier :: main
RParen :: )
Generic :: /admin
Quoted:
rg test 'iPlantMES/apps/web/app/(main)/admin' -S
PowerShell tokenizes it correctly as a single path argument:
StringLiteral :: 'iPlantMES/apps/web/app/(main)/admin'
I also tested the unquoted command directly. In my case, rg split the path and failed with:
rg: /admin: 지정된 파일을 찾을 수 없습니다. (os error 2)
Using PowerShell cmdlets showed the same underlying issue:
Get-Item iPlantMES\apps\web\app\(main)\admin
Result:
Get-Item : A positional parameter cannot be found that accepts argument '$null'.
Workaround:
Always quote paths that include PowerShell metacharacters such as parentheses:
rg test 'iPlantMES/apps/web/app/(main)/admin' -S
Get-Item 'iPlantMES\apps\web\app\(main)\admin'
Suggested fix:
When Codex generates shell commands for Windows PowerShell, it should quote or otherwise safely escape path arguments containing characters such as ( and ).
Confirming on a second project — same trigger pattern, same dialog.
Environment
(main)/,(auth)/)The Mouse Properties dialog opens intermittently while Codex works in this project. I haven't captured a single-command transcript, but the timing matches what's described here and in #9370: it surfaces during sessions where the agent touches files under
src/app/(main)/....(auth)doesn't trigger anything (noauth.cplto resolve to), consistent with thePATHEXTanalysis.Worth cross-linking #9370. That's the older canonical thread, with six independent reporters across Codex CLI, the VS Code extension (0.4.71/74/76), and Google Antigravity, but the discussion got pulled toward a
REPORT_ALTERNATE_KEYS/ Kitty Keyboard Protocol theory before settling on the same(main)cause @jhseo-tec writes up cleanly here. PR #9371 was closed because the original reporter couldn't supply a minimal repro for the kitty theory; this issue has it.Per-session workaround for anyone hitting this in the meantime — strip
.CPLfromPATHEXTin the shell that invokes Codex:This doesn't fix the underlying parsing (
(main)still gets evaluated as a sub-expression), butmainno longer resolves to anything launchable, so you get the$nullparameter error without the Control Panel popup. The Codex command still fails on that file, but no dialog.Confirming this still reproduces on Codex Desktop for Windows.
Environment:
OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0codex-cli 0.125.0Microsoft Windows NT 10.0.26200.05.1.26100.8457v24.14.1src/app/(main)/...Observed again on 2026-05-31 02:43:06 +08:00. Process snapshot:
The parent process had already exited by the time I checked, which fits a short-lived shell command launching
main.cpl.Local diagnosis matches this issue:
src/app/(main)/...is parsed as an expression.mainresolves on Windows toC:\Windows\system32\main.cpl."src/app/(main)/...", avoids the dialog and passes the path correctly.This also looks like the concrete root cause behind the broader Mouse Properties report in #9370.
Suggested mitigation:
(and).-LiteralPath.(main)or(auth).Additional evidence from a later occurrence: this time the Codex Desktop UI itself showed the commands that were run immediately before the Mouse Properties dialog appeared.
The visible commands included unquoted pathspecs with Next.js route-group folders, for example:
The Mouse Properties dialog appeared while those commands were being run.
So this is not just a suspected background process chain: Codex generated/executed PowerShell commands containing unquoted
src/app/(main)/...path arguments. Quoting those pathspecs individually avoids the issue, e.g.:This also suggests
git diff -- <pathspecs...>needs the same Windows PowerShell quoting treatment asrgandGet-Contentcommands.