fix(install): recover CoDev Code's native binary instead of dead-ending the wizard - #256
Merged
Merged
Conversation
`codev-code` ships the same shape as Claude Code: a tiny placeholder at `bin/codev.exe` plus a postinstall that copies the real ~170 MB binary out of a platform-specific optionalDependency. When that postinstall doesn't place the binary, the placeholder stays — 476 bytes of POSIX shell under an `.exe` name — and npm still exits 0, because the download it skipped was optional. `installAndVerify` then runs `codev --version` and gets, on Windows: This version of C:\Program Files\nodejs\node_modules\codev-code\bin\ codev.exe is not compatible with the version of Windows you're running. That is the PE loader refusing a file with no PE header, but it reads as "wrong architecture" or "unsupported Windows", so users go audit their OS and find nothing. `installAndVerify` already recovers this exact class of failure for `claude-code` and for `codex` on Windows, but had nothing for `codev-code` — which ToolSelect locks into every selection, so the failed row empties the survivor set and `SetupApp` parks on `install-failed` with nothing installed and no way forward. - Add `recoverCodevNativeBinary`, mirroring the Claude Code recovery: re-run the package's own `postinstall.mjs`, re-verify, then force a reinstall and re-verify. Verified end-to-end against a real broken install: 476-byte placeholder → 176 MB binary → `--version` answers. - The recovery reinstall carries `--force`. npm re-runs install scripts only when it considers the tree changed, so once the placeholder is in place a plain `npm i -g codev-code` can report success without touching it, and every retry reproduces the same failure. - Report the placeholder rather than the loader error, but only when the size probe positively confirms it. A full-size binary that still won't run is a genuine incompatibility and keeps its own message. - Add the matching launch-time hint in `runAgent`, alongside Claude's. Also fix a second bug visible in the same report: `verifyInstall` ran the bare CLI name through PATH, so on a machine that had installed before, `codev` resolved to CoDev's own `~/.codev-hub/bin/codev.cmd`, which re-execs `codevhub codev --version`. Verification measured our shim and prefixed the agent's real error with our "Starting CoDev Code..." banner — the line users reported inside the install error. It now strips the shim dir from the child's PATH, exactly as `run.ts` does when launching an agent for real. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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 users hit
codevhub installfails on the CoDev Code row and the wizard stops there:Nothing follows. That is not a rendering artifact — CoDev Code is locked into
every selection by
ToolSelect, so its failure emptieshandleInstallDone'ssurvivor set and
SetupAppparks on the terminalinstall-failedphase. Theuser cannot reach configure, and re-running
installreproduces it exactly.Why
codev-codeships the same shape as Claude Code: a placeholder atbin/codev.exeplus apostinstall.mjsthat copies the real ~170 MB binary outof a platform-specific
optionalDependency. When the postinstall doesn't placeit, the placeholder stays — and it is 476 bytes of POSIX shell script carried
under an
.exename, because that is the package's declaredbinon everyplatform. npm still exits 0, because the download it skipped was optional.
Windows then hands that text file to the PE loader, which refuses a file with no
PE header and reports it through cmd.exe as "not compatible with the version of
Windows you're running". The message names neither npm nor a postinstall, so it
reads as a wrong-architecture or unsupported-OS problem and sends people off to
audit their Windows build, where they find nothing wrong.
installAndVerifyalready recovers this exact class of failure forclaude-code(postinstall + reinstall) and forcodexon Windows. It hadnothing for
codev-code.The fix
recoverCodevNativeBinary, mirroring the Claude Code recovery: re-run thepackage's own
postinstall.mjs, re-verify, then force a reinstall andre-verify. Verified end-to-end against a genuinely broken install —
476-byte placeholder → 176 MB binary →
--versionanswers1.18.4-8.--force. npm re-runs install scripts onlywhen it considers the tree changed, so once the placeholder is in place a plain
npm i -g codev-codecan report success without ever touching it. Without--forcethe recovery would be a no-op on exactly the machines that need it.Stage 1 sidesteps npm entirely for the same reason.
probe positively confirms the stub. A full-size binary that still won't run is
a genuine incompatibility and keeps its own message; rewriting that would be
the same mistake in reverse.
runAgent, alongside the existing Claude one.Second bug, visible in the same report
That
Starting CoDev Code...in the middle of the error is ours.verifyInstallran the bare CLI name through PATH, so on a machine that had installed before,
codevresolved to CoDev's own~/.codev-hub/bin/codev.cmd, which re-execscodevhub codev --version→runAgent. Verification was measuring our shimrather than the binary npm had just written, and spawning a second hub process to
do it. It now strips the shim dir from the child's PATH, exactly as
run.tsalready does when it launches an agent for real.
Tests
10 new tests in
tests/lib/npm.test.ts. Each was mutation-checked against theproduction change it covers — removing the recovery wiring fails 4, removing
--forcefails 1, removing the shim strip fails 1.Full suite: 1424 passed, 2 skipped.
pnpm fix,pnpm typecheck,pnpm buildand the bundled
node dist/index.js --versionsmoke run all pass.Follow-up, not in this PR
Recovery makes the common case succeed, but if it fails the wizard still parks on
install-failedwith no way forward, because the locked flagship agent is thewhole survivor set. Whether a locked tool should be able to strand the flow is a
design question worth taking separately.
🤖 Generated with Claude Code