[Bug?][behavior question]: yarn with corepack still requires yarn set version to use the correct version #6480
Labels
bug
Something isn't working
stale
Issues that didn't get attention
waiting for feedback
Will autoclose in a while unless more data are provided
Self-service
Describe the bug
Hello, I am documenting a confusing (to me) the behavior of corepack and yarn.
TLDR: The issue is that
corepack use
does not set the correct version of yarn after yarn has set itself withyarn set version
. After that command is run corepack is unable to mutate the yarn version even if the project is using a different version of yarn.Only way around it is to either set a yarn-path to a binary. Or call
yarn set version
Expected Behavior
To me, it seems like yarn should not be superseding
corepack use
command e.g.corepack use [email protected]
should set current yarn binary to 4.4.1.Actual Behavior
Based on documentation of yarn set version, this command controls the version of the package used by corepack.
However this seems weird if corepack specifically calls
use [email protected]
, even when specifically installing a version such ascorepack install yarn@stable
which should then make yarn be 4.4.1. Instead it installs the binary of 4.4.1 but yarn never adjust itself.Workarounds
This is only resolved by doing a
yarn set version 4.4.1
oryarn set version 1.22.22
whatever is needed. This needs to be run on the corepack version of yarn which seems to disregard any of the downloaded binaries in favor of whateveryarn set version
has selected.Other discussions
To reproduce
Example with node 20
Environment
System: OS: macOS 14.6.1 CPU: (14) arm64 Apple M3 Max Binaries: Node: 18.20.4 - /private/var/folders/cx/hhb3k6dn74sc9w1nt91xr33r0000gn/T/xfs-a12af720/node Yarn: 4.4.1 - /private/var/folders/cx/hhb3k6dn74sc9w1nt91xr33r0000gn/T/xfs-a12af720/yarn npm: 10.7.0 - ~/.local/state/fnm_multishells/3107_1725262633526/bin/npm
Additional context
No response
The text was updated successfully, but these errors were encountered: