Repository navigation
fix(opencode): make the npm postinstall failure diagnosable and its Windows fallback work - #355
Merged
Merged
Conversation
…indows fallback work The postinstall swallowed every error and ended with a message that only named packages to retry, so an install that failed because the platform package never arrived, because the fallback npm fetch failed, or because the installed binary refused to run all looked identical. Each step now records a one-line reason (spawn error, exit code or signal, first stderr line of `--version`) and the final error lists them under "What was tried". The fallback fetch spawned `npm` without a shell; on Windows that is npm.cmd, which Node has refused to spawn without a shell since 18.20.2 / 20.12.2 (CVE-2024-27980), so the fallback silently never ran there. It now goes through cmd.exe as the Node docs recommend. The placeholder stub that runs when the postinstall did not points npm 12 users at --allow-scripts, since npm 12 blocks install scripts on global installs by default. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtPnKQ9ATvc9kd1v74zC4Y
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtPnKQ9ATvc9kd1v74zC4Y
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.
Summary
A user on Windows (npm 12.0.2) hit
npm i -g codev-codeending with "It seems your package manager failed to install the right codev CLI package. Try manually installing …". Investigating that showed the message is reachable from three unrelated failures and the script gives no way to tell them apart, plus one path that cannot work on Windows at all.installPackageandverifyBinarynow report why they failed instead of returning false: the platform package was not installed by the package manager (with the resolve error), the fallbacknpm installcould not start or exited non-zero, or the copied binary's--versionfailed (spawn error, exit code or signal, and the first stderr line — stderr is piped rather than ignored, because an antivirus or application-control block says so there).maincollects one line per package and step and appends a What was tried list to the final error.npmwith no shell. On Windows that isnpm.cmd, which Node has refused to spawn without a shell since 18.20.2 / 20.12.2 (CVE-2024-27980), so it failed instantly and silently on every supported Node. It now spawnscmd.exe /d /s /c npm …as the Node docs recommend; Node still quotes each argument, so a temp path with spaces is fine. Upstream opencode's script has the same bug.npx npm@12.0.2 install -g codev-codeleaves the placeholder in place and warns). The placeholder stub's message now showsnpm install -g codev-code --allow-scripts=codev-code.Both scripts are upstream files; their
DIVERGENCES.mdrows are extended. CHANGELOG has an Install entry.Test plan
node --checkand prettier on the scriptcodev-code-darwin-arm64@1.18.23-2succeeds,bin/codev.exe --versionprints 1.18.23-2What was tried:listing the resolve failure andnpm install … exited with 1installed, but … exited with code 3: <stderr line>bun typecheckinpackages/opencodenpm i -g codev-code --omit=optional --allow-scripts=codev-code)🤖 Generated with Claude Code
https://claude.ai/code/session_01UtPnKQ9ATvc9kd1v74zC4Y