Skip to content

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

Open
@MikeMcC399

Description

@MikeMcC399

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions