berry: [Bug?]: `yarn set version berry` installs the version 4 instead of 3?

Self-service

  • I’d be willing to implement a fix

Describe the bug

When users install our project, we used to do the yarn set version berry, which installed the version 3 and now it tries to install the version 4. Our project is still on Node v16 (upgrade to v18 is in progress) and Yarn v4 is failing to install.

I tried all the commands from the docs and none of them can install the v3.

For example:

yarn set version https://repo.yarnpkg.com/3.6.4/packages/yarnpkg-cli/bin/yarn.js
Resolving https://repo.yarnpkg.com/3.6.4/packages/yarnpkg-cli/bin/yarn.js to a url...
error An unexpected error occurred: "Release not found: https://repo.yarnpkg.com/3.6.4/packages/yarnpkg-cli/bin/yarn.js".

Is there any other way to set the version to 3.x?

thanks

To reproduce

  1. Have Yarn v1 installed.
  2. Try to set version to v3.6.4: yarn set version https://repo.yarnpkg.com/3.6.4/packages/yarnpkg-cli/bin/yarn.js

Environment

System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.20.0
    Yarn: 1.22.19
    npm: 9.8.1
  npmPackages:
    jest: ^29.5.0 => 29.5.0

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 9
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Actually I think I understand the confusion now - I got mistaken by @i4rilu’s and @wojtekmaj’s posts, I now see your initial problem was different from what I thought. Sorry about that.

The yarn set version berry command (and the berry selector) is an alias for stable, but we never intended to guarantee that it would be an alias for “2.x”. As I mentioned “berry” is the name of the modern codebase, so its purpose was mostly to make clear that it would be different from 1.x (something that “stable” didn’t properly convey at the time). Back in 2.x it was pointing to the latest stable 2.x release, then the latest 3.x release, etc. So this thread is “not a bug”, it’s expected that berry always points to the latest release.

However, running yarn set version 3.6.4 should work, but due to an actual bug (the one I mentioned in my previous message) it currently doesn’t. I’m working on that, but for now I’m afraid there isn’t a better option than the environment variable I mentioned (or to tell your users to install Yarn via Corepack). I hope to have it solved tomorrow or Wednesday.

@piero87 this seems to be a different issue, please open a new thread (I already misunderstood the problem statement once, I want to be sure we don’t get confused again).

@arcanis I don’t see how would that help me with the user projects. I have a possible workaround, need to test it. I really dont want to use the v4 with the YARN_IGNORE_NODE flag, as I don’t know the repercussions it would cause.

But still, its not good that you push v4 into the berry keyword. When v2 came out, there was a part in the docs which said something like: berry will always be Yarn version 2. Then came v3 and it was berry, same with v4.

> node -v
v16.20.0
> corepack enable
> yarn set version 3.6.4
Usage Error: This tool requires a Node version compatible with >=18.12.0 (got 16.20.0). Upgrade Node, or set `YARN_IGNORE_NODE=1` in your environment.

No changes in the error.