Skip to content

fix(nodejs plugin): warn when Corepack is enabled but unavailable#2888

Open
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-chaksw
Open

fix(nodejs plugin): warn when Corepack is enabled but unavailable#2888
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-chaksw

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2791.

When DEVBOX_COREPACK_ENABLED is set, the nodejs plugin's init_hook runs corepack enable. Some Node packages no longer bundle Corepack — notably nodejs-slim (nixpkgs#487796) and Node.js 25+. In those cases the corepack binary is missing, the enable step failed silently, and the user later hit a cryptic error with no indication of the cause:

bash: corepack: command not found
bash: yarn: command not found

Fix

  • plugins/nodejs/setup-corepack.mjs: detect the missing corepack binary (ENOENT) when running corepack enable and print an actionable warning pointing the user to add the corepack package, 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.

    [devbox] Warning: DEVBOX_COREPACK_ENABLED is set but the `corepack` command
    was not found. Some Node packages (such as nodejs-slim, and Node.js 25+) no
    longer bundle Corepack. Add the `corepack` package to your devbox.json (for
    example, run `devbox add corepack`) to use Yarn or pnpm.
    
  • plugins/nodejs.json: bump the plugin version to 0.0.5 (so existing projects regenerate the script) and clarify the readme to call out nodejs-slim alongside Node.js 25+.

  • testscripts/plugin/nodejs_corepack_autodetect.test.txt: add a case that switches the project to nodejs-slim and asserts the shell still initializes successfully and the warning is printed.

How was it tested?

  • go test ./plugins/... passes.
  • node --check on the script passes, and I exercised it directly under Node 22:
    • no-op when DEVBOX_COREPACK_ENABLED is unset;
    • with corepack on PATH: installs the yarn/pnpm/... shims into the bin dir, exit 0;
    • with corepack removed from PATH: prints the warning, exits 0, does not crash.
  • Added testscript coverage for the nodejs-slim (no bundled Corepack) path.

cc @apgrucza (issue reporter)


Generated by Claude Code

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
Copilot AI review requested due to automatic review settings June 22, 2026 14:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ENOENT detection around corepack enable and 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.

Comment thread plugins/nodejs/setup-corepack.mjs Outdated
Comment thread testscripts/plugin/nodejs_corepack_autodetect.test.txt Outdated
- 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".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Node.js plugin fails to run corepack when using nodejs-slim

3 participants