How to upgrade to yarn 4

Hi, I need some documentation on how to upgrade to yarn 4 on the virtual machine.

Thanks

Hi @smasseroni :wave:

The official docs recommend this command to upgrade the installed yarn version:

yarn set version stable

I tested it here, first printing the yarn version, then running yarn set version stable and then printing the version again: Bitrise - Mobile Continuous Integration and Delivery - iOS & Android Build Automation

And it seems to do the job:

+------------------------------------------------------------------------------+
| (0) Print yarn version                                                       |
+------------------------------------------------------------------------------+
| id: script                                                                   |
| version: 1.2.1                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2024-05-17T09:00:52Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
+ yarn --version
1.22.21
|                                                                              |
+---+---------------------------------------------------------------+----------+
| e[32;1m✓e[0m | e[32;1mPrint yarn version                                           e[0m | 3.17 sec |
+---+---------------------------------------------------------------+----------+

                                        â–¼

+------------------------------------------------------------------------------+
| (1) Install latest stable yarn                                               |
+------------------------------------------------------------------------------+
| id: script                                                                   |
| version: 1.2.1                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2024-05-17T09:00:53Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
+ yarn set version stable
➤ YN0000: You don't seem to have Corepack enabled; we'll have to rely on yarnPath instead
➤ YN0000: Downloading https://repo.yarnpkg.com/4.2.2/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.2.2.cjs
➤ YN0000: Done with warnings in 0s 108ms
|                                                                              |
+---+---------------------------------------------------------------+----------+
| e[32;1m✓e[0m | e[32;1mInstall latest stable yarn                                   e[0m | 1.80 sec |
+---+---------------------------------------------------------------+----------+

                                        â–¼

+------------------------------------------------------------------------------+
| (2) Print yarn version                                                       |
+------------------------------------------------------------------------------+
| id: script                                                                   |
| version: 1.2.1                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2024-05-17T09:00:55Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
+ yarn --version
4.2.2
|                                                                              |
+---+---------------------------------------------------------------+----------+
| e[32;1m✓e[0m | e[32;1mPrint yarn version                                           e[0m | 0.87 sec |
+---+---------------------------------------------------------------+----------+

To install a specific yarn version:

yarn set version 2.4.1

You can see an example build here: Bitrise - Mobile Continuous Integration and Delivery - iOS & Android Build Automation