Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?][behavior question]: yarn with corepack still requires yarn set version to use the correct version #6480

Open
1 task
FrederickEngelhardt opened this issue Sep 2, 2024 · 1 comment
Labels
bug Something isn't working waiting for feedback Will autoclose in a while unless more data are provided

Comments

@FrederickEngelhardt
Copy link

Self-service

  • I'd be willing to implement a fix

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 with yarn 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 as corepack 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 or yarn 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 whatever yarn set version has selected.

Other discussions

To reproduce

Example with node 20

node -v #should be 20
take corepack-test # makes a test directory, make sure to do this outside a yarn workspace just in case
command -v yarn # should be nothing
corepack enable # should enable corepack
corepack use [email protected]
yarn -v # should be 4.3.1
corepack use [email protected]
yarn -v # should be 4.4.1
yarn set version 4.4.0
yarn -v # should be 4.4.0
corepack use [email protected]
yarn -v # This will say 4.4.0 when we would expect 4.4.1

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

@FrederickEngelhardt FrederickEngelhardt added the bug Something isn't working label Sep 2, 2024
@arcanis
Copy link
Member

arcanis commented Sep 2, 2024

corepack use [email protected]
yarn -v # should be 4.4.1
yarn set version 4.4.0
yarn -v # should be 4.4.0
corepack use [email protected]
yarn -v # This will say 4.4.0 when we would expect 4.4.1

I don't repro; not sure why it wouldn't work either, corepack use just sets the packageManager field and so does yarn set version starting from 4.0.

@arcanis arcanis added the waiting for feedback Will autoclose in a while unless more data are provided label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for feedback Will autoclose in a while unless more data are provided
Projects
None yet
Development

No branches or pull requests

2 participants