Skip to content

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

Closed as not planned

Description

@brunozoric

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

Activity

  1. i4rilu commented on Oct 23, 2023

    @i4rilu

    Slightly different, but related issue:

    /tmp % yarn --version
    1.22.19
    /tmp % yarn set version 3.6.1
    ➤ YN0000: Done in 0s 4ms
    /tmp % yarn --version
    4.0.0
    /tmp %
    
  2. wojtekmaj commented on Oct 23, 2023

    @wojtekmaj
    Contributor

    Not directly addressing your report, but you may want to revisit the way you're installing Yarn in the first place. Perhaps use Corepack (as recommended) to get rid of Yarn v1 dependency altogether?

  3. brunozoric commented on Oct 23, 2023

    @brunozoric
    Author
    > 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.

  4. wojtekmaj commented on Oct 23, 2023

    @wojtekmaj
    Contributor

    yarn set version 3.6.4

    This command is ran by Yarn 4, hence the error. If your server stil runs Node 16, you upgraded Yarn to version 4 too fast.

    But, if you really want to dig deeper into this workaround, try setting packageManager in package.json, so instead of yarn set version 3.6.4 run npm pkg set packageManager="[email protected]". This way, you won't use Yarn to downgrade Yarn.

  5. arcanis commented on Oct 23, 2023

    @arcanis
    Member

    As a stopgap, can you try setting export YARN_IGNORE_NODE=1 in your CI?

  6. changed the title [-][Bug?]: Set version from the repo url does not work[/-] [+][Bug?]: "This tool requires a Node version compatible" when running `yarn set version`[/+] on Oct 23, 2023
  7. pinned this issue on Oct 23, 2023
  8. brunozoric commented on Oct 23, 2023

    @brunozoric
    Author

    @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.

  9. arcanis commented on Oct 23, 2023

    @arcanis
  10. Piero87 commented on Oct 23, 2023

    @Piero87
  11. arcanis commented on Oct 23, 2023

    @arcanis
    Member

    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).

  12. wojtekmaj commented on Oct 23, 2023

    @wojtekmaj
  13. changed the title [-][Bug?]: "This tool requires a Node version compatible" when running `yarn set version`[/-] [+][Bug?]: `yarn set version berry` installs the version 4 instead of 3?[/+] on Oct 23, 2023
  14. Piero87 commented on Oct 23, 2023

    @Piero87
  15. arcanis commented on Oct 23, 2023

    @arcanis
    Member

    I opened a thread to consolidate information around the yarn set version bug at #5829. Closing this one as duplicate.

  16. rdewolff commented on Oct 30, 2023

    @rdewolff

    Thanks for the tip, helped me solved an issue while deploying on vercel

  17. bamf2077 commented on Dec 6, 2023

    @bamf2077

    I think berry = latest = stable, just like this repository with the same name, represents the mainline development version of Yarn.

    berry is not a code name of specific version like Node v20 LTS Iron, Debian 12 bookworm, Android 13 Tiramisu, so there is no Yarn v3 c*** or v4 d***.

  18. popuguytheparrot commented on Dec 23, 2023

    @popuguytheparrot

    i have issue with not install 4 version

    image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions