Repository navigation
feat(shims): add a corepack shim that runs corepack in the container - #17
Merged
Merged
Conversation
Without a shim, `corepack` resolved to whatever host Node sits at the end of PATH (kept there for local mode), so it ran on the host. bin/corepack now goes through docker_exec like node/npm/npx/yarn/pnpm. needs_corepack() always sets corepack up for the corepack shim, so Node 25+ images (no bundled corepack, default node:26) get the same pinned copy the yarn/pnpm shims install into ~/.cache/node-shims/corepack; older images use their bundled one. Local mode still finds the host corepack via exec_local. is_install_command() treats `corepack use|up` and `corepack <pm> <install>` as installs, so the node_modules platform marker stays correct. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 4 tasks
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.
Problem
node,npm,npx,yarnandpnpmare shimmed, butcorepackwas not. Typingcorepackresolved to whatever comes later on PATH, e.g. a host Node kept at the end of PATH for local mode, so it ran on the host, outside the container.Changes
bin/corepack: new shim, identical tobin/node/bin/pnpm(docker_exec "$(basename "$0")").bin/common.shneeds_corepack(): always true forcorepack(same asyarn/pnpm). The existingcorepack_setup_scriptthen makes corepack available before the call: on Node 25+ images (defaultnode:26-alpine), which no longer bundle corepack, it puts the pinned copy from~/.cache/node-shims/corepack(NODE_SHIMS_COREPACK_VERSION, default 0.36.0) on PATH, installing it once if missing. Older images use their bundled corepack.corepack enable/corepack installalso run first, as they do for yarn/pnpm.is_install_command():corepack use|upandcorepack <pm>[@ver] <install subcommand>(e.g.corepack pnpm install,corepack yarn) count as installs, so thenode_modulesplatform marker is recorded.--help/--versionstill never count.NODE_SHIMS_MODE=local corepackgoes throughexec_local, which skips the shims dir and finds the hostcorepack. Dev-server port mapping already matches on the full argv (corepack pnpm dev).scripts/install-shims.sh("Available commands"),scripts/install-agent-skill.sh(CLAUDE.md pointer text),skills/node-docker-shims/SKILL.md, a comment inbin/node-shell.corepackadded to the per-tool loop; new tests for corepack setup (pinned copy on PATH, cache dir mount,NODE_SHIMS_COREPACK_VERSION), local override plus the shim winning over a host corepack at the end of PATH, port mapping, and the platform marker forcorepackinstall vs non-install calls.corepack --versionandcorepack pnpm --version(withpackageManager) on the default image, andcorepack pnpm --versionon.nvmrc22 (bundled corepack).Testing
bats test/unitin anubuntu:24.04container (bats from apt, matching CI): 43/43 pass.bats test/uniton macOS: 39/43. The 4 failures (project is mounted at its real path,absolute path arguments outside the project,op run parent forwards host env,node-shell mounts the corepack dir) also fail on unmodifiedmain. They are macOS-specific (/varvs/private/var, Linux pnpm store path), and CI runs on Linux.shellcheck -S warning bin/corepack bin/common.sh bin/node-shell scripts/install-shims.sh scripts/install-agent-skill.sh: clean.bats test/smokeon macOS with Docker Desktop: the new corepack smoke test passes, along with node, npm, yarn, pnpm and Docker-from-npm-scripts. 4 tests fail (yarn install ... NODE_SHIMS_LOCAL,pnpm shares one store ...,npx wrangler builds a workerwith npmECOMPROMISED,op run), and the same 4 also fail on unmodifiedorigin/mainon this machine, so they come from the environment."packageManager": "pnpm@11.28.10":corepack --versiongives0.36.0(pinned copy),corepack pnpm --versiongives11.28.10NODE_IMAGE=node:22-alpine:corepack --versiongives0.34.6(bundled),corepack pnpm --versiongives11.28.10corepack --versiongives0.36.0(the shim wins), andNODE_SHIMS_MODE=local corepack --versiongives0.34.2(host corepack)Notes
NODE_SHIMS_MODE=local corepackfails with the existing "not found outside the Docker shims" message. That is the intended behaviour, but local mode then needs a host corepack (npm i -g corepack) to be useful.corepack:corepack pnpm exec wrangler deploygets no Cloudflare credentials. This fails closed.pnpm exec wrangler ...orNODE_SHIMS_WRANGLER_AUTH=1still work.🤖 Generated with Claude Code