Skip to content

fix(use): select the default version when offline - #905

Open
Aschenbath wants to merge 1 commit into
nodejs:mainfrom
Aschenbath:fix/offline-use-default
Open

Aschenbath wants to merge 1 commit into
nodejs:mainfrom
Aschenbath:fix/offline-use-default

Conversation

@Aschenbath

@Aschenbath Aschenbath commented Oct 14, 2026 •

Copy link
Copy Markdown

corepack use yarn currently queries registry version lists even after corepack install -g yarn@4.8.0. With COREPACK_ENABLE_NETWORK=0, this fails although the selected default is cached.

When the network is disabled and the version is omitted (including yarn@), use the existing default-version resolver after loading .corepack.env. This preserves the selected Last Known Good release and its integrity hash even when a newer release is cached. Online resolution and explicit versions, tags, and ranges retain their existing behavior. The command help and README describe the offline behavior.

Fixes #704.

Validation on Node.js 22.23.3 in WSL:

  • corepack yarn build, corepack yarn typecheck, and corepack yarn lint --max-warnings=0 passed.
  • NOCK_ENV=replay corepack yarn test run --retry=0: 180 passed and one existing expected failure across eight files. The nine new regressions include default selection, .corepack.env, explicit requests, a missing default, and online resolution. Before the production fix, three regressions failed and the other 14 UseCommand tests passed; all 17 pass with the fix.
  • Downloaded the published Yarn 4.8.0 and 4.18.0 releases into an isolated cache. With network access disabled in both Corepack and Yarn, bare use yarn selected the 4.8.0 default, wrote its integrity hash, and completed installation. Explicit use yarn@4.18.0 also worked; use yarn@latest failed without changing the manifest.

Cross-platform CI passed all ten jobs at a9575754509fcea9b7f2f85fae1bdb5852def35b: the existing Tests workflow on Node.js 22, 24, and 26 across Linux, macOS, and Windows, plus type and lint checks. The upstream workflow still requires maintainer approval.

Implementation and automated validation were performed by Codex.

Signed-off-by: Nash Aschenbath <wwh86696@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow corepack use with default package manager when network disabled COREPACK_ENABLE_NETWORK=0

1 participant