The reporter clicked Update all. npm 11.19.0 ran
`npm install -g --prefix /opt/homebrew @anthropic-ai/claude-code@latest`,
logged "reify failed optional dependency …claude-code-darwin-arm64" and
exited 0. Claude Code 2.1.299's postinstall soft-fails without its native
package, so bin/claude.exe was left as the stub that says "Error: claude
native binary not installed." and exits 1. UpdateCLI saw npm succeed and
read the new version from package.json (proc.Version never runs an npm
CLI), so the update was reported as done.
Now, after an update that succeeds, UpdateCLI runs `<cli> --version` once
(runsBroken). It uses a 30s timeout, the update's env (npm's folder first
on PATH) and no stdin. Only a run that exits non-zero and prints no version
counts as broken. A run that didn't start, timed out, or exited 127
(interpreter not found) is unknown, not broken.
- npm installs that magpie runs as the user: the version just installed is
installed once more with --include=optional, which is how the reporter
mended theirs, and the check runs again.
- npm installs needing administrator rights get no second prompt.
- If the CLI still fails, or it was installed some other way (bun, pnpm,
brew, self), the update fails. The message carries what the CLI said and
how to reinstall it, e.g. `npm install -g --prefix /opt/homebrew
@anthropic-ai/claude-code@2.1.299 --include=optional`.
Both Update all and a row's Update pill go through UpdateCLI, so both are
covered. The GUI already shows an update's error, so it is unchanged.
What was run:
- TestUpdateCLIChecksItRuns: a fake Homebrew prefix with Claude Code's
package and the stub as the reporter found them. It covers the update
mended by the second install, a working update that runs nothing more,
and an update left broken that fails with the reinstall command. With
the check disabled it fails ("not mended: <nil>").
- TestRunsBrokenOnlyWhenSure: a version said with a non-zero exit, exit 127
and a silent exit 0 are not broken.
- gofmt -l; go vet for darwin, linux (nogui) and windows.
- go test ./internal/agent/ -timeout 45m passes (856s). The first run hit
the default 10m timeout at load ~290 while in TestOmo, with no failure.
- go test ./internal/proc/ passes, TestNoCommandBypassesProc included.
Not tried: a real npm install that drops the native package, and Windows,
where the new tests skip because their CLIs are shell scripts.