Allow `corepack use` with default package manager when network disabled `COREPACK_ENABLE_NETWORK=0`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 279
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
What would you like?
corepack use should default to the package manager version stored in lastKnownGood.json when network connections are disabled with COREPACK_ENABLE_NETWORK=0.
For example
corepack use yarn
should work if previously Yarn was globally installed:
corepack install -g yarn@<specific-version>
Why is this needed?
Version-independent workflows including for example corepack use yarn should still work with no network available.
Steps to reproduce
Ubuntu 22.04.2 LTS, Node.js 22.14.0 LTS, Corepack 0.32.0
rm -rf ~/.cache/node/corepack
corepack install -g yarn@4.8.0
export COREPACK_ENABLE_NETWORK=0
cd $(mktemp -d)
corepack use yarn # fails
corepack use yarn@4.8.0 # succeeds
Logs
Failure
$ corepack use yarn # fails
Usage Error: Network access disabled by the environment; can't reach npm repository https://registry.npmjs.org
$ corepack use <pattern>
Success
$ corepack use yarn@4.8.0 # succeeds
Installing yarn@4.8.0 in the project...
➤ YN0000: · Yarn 4.8.0
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 0s 78ms
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the corepack use command entry point and trace how a package manager version is resolved when COREPACK_ENABLE_NETWORK=0. Reproduce the failure using the commands and environment in the issue, then verify that corepack use yarn selects the globally installed version from lastKnownGood.json without network access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100