v0.2.2 - find the CLI the Codex desktop app already installed
v0.2.2 — find the CLI the Codex desktop app already installed
The symptom
On a machine where the Codex desktop app was installed, the plugin still reported:
spawn codex ENOENT path: 'codex' spawnargs: [ 'app-server' ]
The CLI was there all along: the desktop installer puts it in its own directory and appends it to the user environment. But DSH is Electron, and a process that inherited a stale environment — one already running, or one started by explorer.exe, which keeps the environment it had at logon — cannot see that directory. So "Codex is installed" and "Codex is missing" looked exactly the same.
The fix
lib/resolve-bin.js no longer trusts PATH alone. It searches, in order:
| Platform | Locations |
|---|---|
| Windows | PATH → %LOCALAPPDATA%\Programs\OpenAI\Codex\bin (the desktop app's own CLI) → %LOCALAPPDATA%\OpenAI\Codex\bin → %ProgramFiles%\OpenAI\Codex\bin → %APPDATA%\npm → %LOCALAPPDATA%\pnpm → ~/.codex/packages/standalone/current/bin → ~/.codex/bin → ~/.codex/plugins/.plugin-appserver → the standalone releases/<version>/bin tree, newest first |
| macOS / Linux | PATH → ~/.codex/packages/standalone/current/bin → ~/.codex/bin → ~/.local/bin → /usr/local/bin → /opt/homebrew/bin → /usr/bin |
- The resolved absolute path is logged and exposed on
GET /dsh-native-codex-cli/health, so support questions answer themselves. - An explicit
codexBinis still respected verbatim — the search never silently substitutes a different binary. - A bare
codexBinname is searched for too. - When nothing is found, the error now lists every directory that was searched.
Verified on a real machine with the Codex desktop app installed, with the Codex directory removed from PATH:
live resolution (stale PATH): C:\Users\<you>\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
Tests
test/resolve-bin-check.mjs injects a fake environment and asserts the candidate list for Windows and POSIX (including that PATH entries come first and that the desktop app's directory is present). It runs on CI with no Codex installed. Wired into npm run check and the workflow.
Still true from v0.2.1
A missing CLI can no longer take DSH down: the default 'error' listener, the spawn/initialize race, and the actionable message are all in place, guarded by test/spawn-failure-check.mjs.
Install
dsh plugin --profile desktop add git+https://github.com/447662/dsh-native-codex-cli.gitThen restart DSH.
Full documentation: README (中文) · README (English)