Skip to content

[Bug?]: yarn set version sets yarnPath in .yarnrc.yml when using corepack to manage versions #4063

Closed
@qcn

Description

Self-service

  • I'd be willing to implement a fix

Describe the bug

Corepack is now the recommended way to install/manage Yarn versions and according to the docs it

lets you use different package manager versions across multiple projects without having to check-in the Yarn binary anymore

However, running yarn set version to update Yarn sets yarnPath in the .yarnrc.yml file, so if I check in the other changes made by set version without checking in the binary, trying to run Yarn errors if the binary isn't there (eg. on a fresh checkout).

Given that the documentation says I don't need to check in the Yarn binary, I expect that using the CLI to lock my package manager version in the documented way will not make any changes that would require the binary to be in that location.

To reproduce

  1. Run corepack enable
  2. Create a new directory with a package.json file containing only:
{ "packageManager": "yarn@3.1.0" }
  1. Run yarn -v and observe that it succeeds - corepack is handling it.
  2. Run ls -a and observe that the package.json file is the only file in this directory.
  3. Run yarn set version 3.1.1.
  4. Run rm .yarn/releases/yarn-3.1.1.cjs
  5. Run yarn -v and observe the error:
    Internal Error: The "yarn-path" option has been set, but the specified location doesn't exist.
  6. Run yarn config unset yarnPath
  7. Run yarn -v and observe that it succeeds - corepack is handling it again now that the change yarn set version made to yarn config has been reverted.

Environment

System:
    OS: macOS 11.6.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.19.0 - /private/var/folders/n7/8y3h45rn5jq9lrd744w_m7xh0000gn/T/xfs-8cbd9b83/node
    Yarn: 3.1.1 - /private/var/folders/n7/8y3h45rn5jq9lrd744w_m7xh0000gn/T/xfs-8cbd9b83/yarn
    npm: 6.14.16 - ~/.nvm/versions/node/v14.19.0/bin/npm

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnot a bugstaleIssues that didn't get attentionwaiting for feedbackWill autoclose in a while unless more data are provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions