diff --git a/.github/actions/prepare/action.yml b/.github/actions/prepare/action.yml index b655b3e..55c8926 100644 --- a/.github/actions/prepare/action.yml +++ b/.github/actions/prepare/action.yml @@ -46,6 +46,22 @@ runs: with: node-version: ${{ inputs.node-version }} + # Node 25 and later no longer ship Corepack. Install it next to the active + # Node when it is missing there. Checking `command -v corepack` is not + # enough: on GitHub's runner images a Corepack from the image's own Node + # stays on PATH, which hides the problem until a job runs in a container + # without one. Node 24 and earlier keep their bundled Corepack untouched. + - name: Install Corepack if Node lacks it + shell: bash + env: + COREPACK_VERSION: '0.36.0' + run: | + node_bin="$(dirname "$(command -v node)")" + if [ ! -x "$node_bin/corepack" ]; then + echo "Node $(node --version) has no Corepack; installing corepack@$COREPACK_VERSION." + npm install --global "corepack@$COREPACK_VERSION" + fi + - name: Enable Corepack for Yarn 4 shell: bash run: corepack enable diff --git a/README.md b/README.md index d92b18a..14c25e1 100644 --- a/README.md +++ b/README.md @@ -462,6 +462,14 @@ and would either fail or silently cache Yarn 1's directory for a Yarn 4 repo. The `yarn-cache` input resolves the folder with `yarn config get cacheFolder` after Corepack instead. +**Node 25 and later do not ship Corepack.** When the active Node has no +`corepack` in its bin directory, the action installs a pinned `corepack` there +with `npm install --global` before enabling it. It checks the bin directory +rather than `PATH` because GitHub's runner images leave a Corepack from their +own Node on `PATH`; a job that runs in a container, such as the Playwright +image, has no such leftover and would fail with `corepack: command not found`. +Node 24 and earlier use their bundled Corepack, as before. + This replaced identical local copies in `truenas/webui` and `truenas-connect/ui` and six inline repetitions in `iXsystems/truenas-ui-components`'s `ci-cd.yml`, which had drifted to a floating `'24'` against the others' pinned `24.13.1`.