Bug Description
On Windows, the Codex provider fails to start when the npm global codex.cmd shim is installed under %ProgramFiles%\nodejs.
The same Codex CLI works from the terminal, so this appears related to how Emdash launches Windows .cmd shims through its PTY layer.
Steps to Reproduce
- Install Node.js on Windows so npm global shims are under
%ProgramFiles%\nodejs.
- Install Codex with
npm install -g @openai/codex.
- Confirm
codex --version works in a terminal.
- Open Emdash and start a Codex conversation.
- Observe that Codex fails to start.
Actual vs Expected Behavior
Actual: Emdash fails to launch Codex and the terminal shows:
'"C:\Program Files\nodejs\codex.CMD"' is not recognized as an internal or external command,
operable program or batch file.
On a Chinese Windows locale, this appears as:
'"C:\Program Files\nodejs\codex.CMD"' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Expected: Emdash should start the Codex provider successfully when codex.cmd is installed in the normal Node.js global install location on Windows.
emdash Version
1.1.10
Operating System
Windows
Additional Context
Environment:
- Emdash install path:
%LOCALAPPDATA%\Programs\Emdash
- Node/npm global prefix:
%ProgramFiles%\nodejs
- Codex CLI path:
%ProgramFiles%\nodejs\codex
%ProgramFiles%\nodejs\codex.cmd
%ProgramFiles%\nodejs\codex.ps1
- Codex version:
codex-cli 0.129.0
These commands work successfully from the terminal:
Output:
C:\Program Files\nodejs\codex
C:\Program Files\nodejs\codex.cmd
cmd.exe /d /s /c '"C:\Program Files\nodejs\codex.CMD" --version'
Output:
Directly starting the .cmd shim through node-pty also works:
const pty = require("node-pty");
const p = pty.spawn(
"C:\\Program Files\\nodejs\\codex.cmd",
["--version"],
{
cwd: process.cwd(),
cols: 80,
rows: 24,
env: process.env,
}
);
p.onData((d) => process.stdout.write(d));
p.onExit((e) => console.log("EXIT", e));
Output:
codex-cli 0.129.0
EXIT { exitCode: 0 }
However, launching via cmd.exe through node-pty fails:
const pty = require("node-pty");
const p = pty.spawn(
"C:\\Windows\\System32\\cmd.exe",
["/d", "/s", "/c", "\"C:\\Program Files\\nodejs\\codex.CMD\" --version"],
{
cwd: process.cwd(),
cols: 80,
rows: 24,
env: process.env,
}
);
p.onData((d) => process.stdout.write(d));
p.onExit((e) => console.log("EXIT", e));
Observed output:
The syntax of the command is incorrect.
EXIT { exitCode: 1 }
The issue may be in the Windows .cmd / .bat handling path around:
src/main/core/pty/pty-spawn-platform.ts
Current behavior appears to resolve extensionless codex to a .CMD file and then wrap it with:
cmd.exe /d /s /c "<resolved codex.CMD>" ...
This seems fragile when the resolved command path is under Program Files.
Possible fix directions:
- Avoid wrapping Windows
.cmd / .bat shims through cmd.exe /s /c when node-pty can launch the .cmd file directly.
- Or change the wrapper form to something like
cmd.exe /d /c call "C:\Program Files\nodejs\codex.CMD" ....
- Add a regression test for a provider command resolved to
C:\Program Files\nodejs\codex.CMD.
Workaround:
"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\@openai\codex\bin\codex.js"
Bug Description
On Windows, the Codex provider fails to start when the npm global
codex.cmdshim is installed under%ProgramFiles%\nodejs.The same Codex CLI works from the terminal, so this appears related to how Emdash launches Windows
.cmdshims through its PTY layer.Steps to Reproduce
%ProgramFiles%\nodejs.npm install -g @openai/codex.codex --versionworks in a terminal.Actual vs Expected Behavior
Actual: Emdash fails to launch Codex and the terminal shows:
On a Chinese Windows locale, this appears as:
Expected: Emdash should start the Codex provider successfully when
codex.cmdis installed in the normal Node.js global install location on Windows.emdash Version
1.1.10
Operating System
Windows
Additional Context
Environment:
%LOCALAPPDATA%\Programs\Emdash%ProgramFiles%\nodejs%ProgramFiles%\nodejs\codex%ProgramFiles%\nodejs\codex.cmd%ProgramFiles%\nodejs\codex.ps1codex-cli 0.129.0These commands work successfully from the terminal:
where.exe codexOutput:
Output:
Directly starting the
.cmdshim throughnode-ptyalso works:Output:
However, launching via
cmd.exethroughnode-ptyfails:Observed output:
The issue may be in the Windows
.cmd/.bathandling path around:Current behavior appears to resolve extensionless
codexto a.CMDfile and then wrap it with:This seems fragile when the resolved command path is under
Program Files.Possible fix directions:
.cmd/.batshims throughcmd.exe /s /cwhennode-ptycan launch the.cmdfile directly.cmd.exe /d /c call "C:\Program Files\nodejs\codex.CMD" ....C:\Program Files\nodejs\codex.CMD.Workaround: