fix(nodejs plugin): warn when Corepack is enabled but unavailable#2888
Open
mikeland73 wants to merge 2 commits into
Open
fix(nodejs plugin): warn when Corepack is enabled but unavailable#2888mikeland73 wants to merge 2 commits into
mikeland73 wants to merge 2 commits into
Conversation
When DEVBOX_COREPACK_ENABLED is set, the nodejs plugin's init_hook runs `corepack enable`. Some Node packages no longer bundle Corepack (nodejs-slim, and Node.js 25+), so this silently failed and users later hit a cryptic `corepack: command not found` / `yarn: command not found` without any indication of the cause. Detect the missing `corepack` binary (ENOENT) and print an actionable warning pointing users to add the `corepack` package, instead of failing silently. Other failures (e.g. being offline) are still ignored so they don't block shell initialization. Also clarify the plugin readme to call out nodejs-slim and add a testscript case covering the nodejs-slim path. Fixes #2791
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Node.js plugin’s Corepack setup to explicitly warn (instead of failing silently) when DEVBOX_COREPACK_ENABLED is set but the corepack binary is missing (notably with nodejs-slim and Node.js 25+), and adds test coverage for that scenario.
Changes:
- Add
ENOENTdetection aroundcorepack enableand emit an actionable warning when Corepack is unavailable; skip package-manager activation in that case. - Bump the nodejs plugin version and clarify the plugin readme about
nodejs-slim/ Node.js 25+ Corepack availability. - Extend testscript coverage to assert shell initialization succeeds and the warning is printed when using
nodejs-slim.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| testscripts/plugin/nodejs_corepack_autodetect.test.txt | Adds a nodejs-slim case to verify the Corepack-missing path warns and doesn’t break shell init. |
| plugins/nodejs/setup-corepack.mjs | Adds corepack-missing detection and warning; gates package-manager activation on successful Corepack enablement. |
| plugins/nodejs.json | Bumps plugin version and updates readme to mention nodejs-slim and Node.js 25+ Corepack behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Reword the activation gate comment: activation is skipped on any enableCorepack() failure, not only when Corepack is missing. - Tighten the testscript stderr assertion to match the specific Corepack warning text instead of a generic "command was not found".
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
Fixes #2791.
When
DEVBOX_COREPACK_ENABLEDis set, the nodejs plugin'sinit_hookrunscorepack enable. Some Node packages no longer bundle Corepack — notablynodejs-slim(nixpkgs#487796) and Node.js 25+. In those cases thecorepackbinary is missing, the enable step failed silently, and the user later hit a cryptic error with no indication of the cause:Fix
plugins/nodejs/setup-corepack.mjs: detect the missingcorepackbinary (ENOENT) when runningcorepack enableand print an actionable warning pointing the user to add thecorepackpackage, instead of failing silently. Package-manager activation is skipped when Corepack couldn't be enabled. Other failures (e.g. being offline) are still ignored so they never block shell initialization.plugins/nodejs.json: bump the plugin version to0.0.5(so existing projects regenerate the script) and clarify the readme to call outnodejs-slimalongside Node.js 25+.testscripts/plugin/nodejs_corepack_autodetect.test.txt: add a case that switches the project tonodejs-slimand asserts the shell still initializes successfully and the warning is printed.How was it tested?
go test ./plugins/...passes.node --checkon the script passes, and I exercised it directly under Node 22:DEVBOX_COREPACK_ENABLEDis unset;corepackonPATH: installs theyarn/pnpm/... shims into the bin dir, exit 0;corepackremoved fromPATH: prints the warning, exits 0, does not crash.nodejs-slim(no bundled Corepack) path.cc @apgrucza (issue reporter)
Generated by Claude Code