You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an alternate version of Yarn Modern is installed through corepack install --global, for instance [email protected], the command yarn init, in an empty project directory, attempts to install Yarn Modern 4.5.2.
Desired behavior
If an alternate version of Yarn Modern is installed through corepack install --global, the command yarn init, in an empty project directory, should use the globally installed version, as shown in ~/.cache/node/corepack/lastKnownGood.json.
Corepack documentation Upgrading the global versions specifically mentions yarn init as an example to override the default version.
Environment / versions
Ubuntu 24.04.1 LTS, Node.js 23.6.0
corepack 0.30.0
Using n as Node.js manager
$ corepack disable
rm -rf ~/.cache/node/corepack
corepack enable yarn
corepack install --global [email protected]
cat ~/.cache/node/corepack/lastKnownGood.json
mkdir yarn-init-test
cd yarn-init-test
yarn -v
yarn init -y
Installing [email protected]...
{
"yarn": "4.0.0"
}
4.0.0
! Corepack is about to download https://repo.yarnpkg.com/4.5.2/packages/yarnpkg-cli/bin/yarn.js
? Do you want to continue? [Y/n]
Debug logs
export DEBUG=corepack
$ yarn -v
corepack LastKnownGood file would be located at /home/mike/.cache/node/corepack/lastKnownGood.json +0ms
corepack Search for default version: Found [email protected] in LastKnownGood file +2ms
corepack Checking /home/mike/github/yarn-init-test/package.json +0ms
corepack Checking /home/mike/github/package.json +0ms
corepack Checking /home/mike/package.json +0ms
corepack Checking /home/package.json +0ms
corepack Checking /package.json +1ms
corepack Falling back to [email protected] as no project manifest were found +0ms
corepack Reusing [email protected] found in /home/mike/.cache/node/corepack/v1/yarn/4.0.0 +8ms
4.0.0
$ yarn init -y
corepack LastKnownGood file would be located at /home/mike/.cache/node/corepack/lastKnownGood.json +0ms
corepack Search for default version: Found [email protected] in LastKnownGood file +2ms
corepack Checking /home/mike/github/yarn-init-test/package.json +0ms
corepack Checking /home/mike/github/package.json +0ms
corepack Checking /home/mike/package.json +1ms
corepack Checking /home/package.json +0ms
corepack Checking /package.json +0ms
corepack Falling back to [email protected]+sha224.c2e2e9ed3cdadd6ec250589b3393f71ae56d5ec297af11cec1eba3b4 as no project manifest were found +0ms
corepack Installing [email protected] from https://repo.yarnpkg.com/4.5.2/packages/yarnpkg-cli/bin/yarn.js +4ms
corepack Downloading to /home/mike/.cache/node/corepack/v1/corepack-6201-fa8f55d.d40be +1ms
! Corepack is about to download https://repo.yarnpkg.com/4.5.2/packages/yarnpkg-cli/bin/yarn.js
? Do you want to continue? [Y/n] n
/home/mike/n/lib/node_modules/corepack/dist/lib/corepack.cjs:21635
throw new UsageError(`Aborted by the user`);
^
UsageError: Aborted by the user
at fetchUrlStream (/home/mike/n/lib/node_modules/corepack/dist/lib/corepack.cjs:21635:15)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async download (/home/mike/n/lib/node_modules/corepack/dist/lib/corepack.cjs:21762:18)
at async installVersion (/home/mike/n/lib/node_modules/corepack/dist/lib/corepack.cjs:21854:55)
at async Engine.ensurePackageManager (/home/mike/n/lib/node_modules/corepack/dist/lib/corepack.cjs:22316:32)
at async Engine.executePackageManagerRequest (/home/mike/n/lib/node_modules/corepack/dist/lib/corepack.cjs:22416:25)
at async Object.runMain (/home/mike/n/lib/node_modules/corepack/dist/lib/corepack.cjs:23102:5) {
clipanion: { type: 'usage' }
}
Node.js v23.6.0
Note: the documentation could be made clearer that corepack use creates a package.json if it does not exist. It only mentions that corepack useupdates an existing package.json.
The text was updated successfully, but these errors were encountered:
Current behavior
If an alternate version of Yarn Modern is installed through
corepack install --global
, for instance[email protected]
, the commandyarn init
, in an empty project directory, attempts to install Yarn Modern4.5.2
.Desired behavior
If an alternate version of Yarn Modern is installed through
corepack install --global
, the commandyarn init
, in an empty project directory, should use the globally installed version, as shown in~/.cache/node/corepack/lastKnownGood.json
.Corepack documentation Upgrading the global versions specifically mentions
yarn init
as an example to override the default version.Environment / versions
Ubuntu
24.04.1
LTS, Node.js23.6.0
corepack
0.30.0
Using n as Node.js manager
Steps to reproduce
Logs
Debug logs
export DEBUG=corepack
Note: the documentation could be made clearer that
corepack use
creates apackage.json
if it does not exist. It only mentions thatcorepack use
updates an existingpackage.json
.The text was updated successfully, but these errors were encountered: