fix(codex): detect proxy shims that pass which() but fail on invoke - #155
Open
vanvasten wants to merge 1 commit into
Open
fix(codex): detect proxy shims that pass which() but fail on invoke#155vanvasten wants to merge 1 commit into
vanvasten wants to merge 1 commit into
Conversation
Setup crashed on fresh installs where a codex proxy shim lives on PATH (e.g. cmux CLI shims at $TMPDIR/cmux-cli-shims/.../codex). Bun.which resolved the shim, so codexCliAvailable() returned true; then readCodexPluginState invoked `codex plugin list --json`, the shim exited non-zero with "Error: codex not found in PATH", and the raw error surfaced as a stack trace instead of falling through to the friendly "Codex CLI is required for a full Codex install" message. - codexCliAvailable now probes `codex --version` (3s timeout) after the hasCommand check, memoized per process to avoid re-probing across the ~15 call sites. Non-zero exit or spawn failure -> unavailable. - resetCodexCliAvailabilityMemoForTests exported so tests that mutate PATH can force a re-probe. - Two new tests: POSIX shim that exits non-zero (mimics cmux) and empty PATH fast path. Windows-gated via describe.skipIf since the shim uses #!/bin/sh. bash setup.sh on the reproducing machine now prints the friendly "Codex CLI is required for a full Codex install" and exits 1 cleanly, with no stack trace.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Fresh
./setup.shcrashes with a stack trace on machines where acodexproxy shim sits onPATH— most commonly cmux, which drops a shim at\$TMPDIR/cmux-cli-shims/<uuid>/codex. The shim exists (soBun.whichreturns it), but invoking it just printsError: codex not found in PATHand exits non-zero — soreadCodexPluginStatethrows that raw error and takes setup down.After this fix,
codexCliAvailable()actually verifies codex runs before trusting it. On the reproducing machine, setup now exits cleanly with the existing friendly "Codex CLI is required for a full Codex install" message instead of a stack trace.Summary
Repro
```
$ which codex
/var/folders/.../cmux-cli-shims//codex # cmux shim
$ ./setup.sh
✗ Setup failed: Codex plugin state query failed: Error: codex not found in PATH
at readCodexPluginState (src/lib/codex-install.ts:1516:15)
at async assertFirstInstallDestinationsAbsent (src/lib/codex-install.ts:1147:31)
at async installCodex (src/lib/codex-install.ts:1987:11)
```
After the fix, same machine:
```
$ ./setup.sh
✗ Codex CLI is required for a full Codex install
```
(User then re-runs with `--light` to skip Codex, or installs real codex.)
Test Plan