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

tests: set yarn classic examples as corepack compatible #1068

Closed

Conversation

MikeMcC399
Copy link
Collaborator

@MikeMcC399 MikeMcC399 commented Oct 25, 2023

Issue

If a user has Node.js' experimental Corepack enabled, then invoking yarn (install) in any examples that are intended to use Yarn Classic (version 1) could cause instead Yarn Modern (version 2 and later) to be used. This could be confusing for a user trying out the examples locally. The following examples are affected:

Note that Yarn Modern > Starting with Yarn > Installation describes the preferred way to manage Yarn as being through Corepack. Users may have other projects on their client system, besides github-action, which use Yarn Modern, and so the possibility that Corepack is enabled should be covered.

Changes

The following commands set the desired Yarn Classic version in the examples/yarn-classic directory.

npm uninstall yarn -g
corepack enable
corepack prepare yarn@stable --activate

Then in each directory listed above where Yarn Classic is intended, cd into the respective examples directory and execute the following:

yarn set version classic

Now, if corepack is enabled it will use Yarn Classic and not Yarn Modern.

Verification

Using Node.js 20 according to .node-version, for instance v20.9.0. The following assumes that the repo is already up-to-date with the latest Cypress version.

Yarn Classic

Install Yarn Classic globally and run the update script for Yarn and pnpm:

corepack disable
npm install yarn@latest -g
npm install pnpm@latest -g
git clean -x -d -f
npm ci
./scripts/update-cypress-latest-other.sh
git status

Confirm that Yarn v1.22.19 is used to install in the examples listed above, that there are no errors as follows:

updating yarn lockfile for start-and-yarn-workspaces
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 9.79s.

updating examples/install-command to cypress@latest
yarn add v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ [email protected]
info All dependencies
└─ [email protected]
Done in 6.08s.

updating examples/yarn-classic to cypress@latest
yarn add v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ [email protected]
info All dependencies
└─ [email protected]
Done in 5.28s.

Yarn Modern

Install Yarn Modern globally using corepack and run the update script again:

npm uninstall yarn -g
corepack enable
corepack prepare yarn@stable --activate
git clean -x -d -f
npm ci
./scripts/update-cypress-latest-other.sh
git status

Again, confirm that Yarn v1.22.19 is used to install in the examples above and that there are no errors.

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 force-pushed the yarn-classic-corepack branch from 676499d to 9c0fffd Compare October 27, 2023 07:09
@MikeMcC399 MikeMcC399 marked this pull request as ready for review October 27, 2023 08:32
@MikeMcC399 MikeMcC399 marked this pull request as draft October 27, 2023 08:37
@MikeMcC399 MikeMcC399 marked this pull request as ready for review October 27, 2023 08:45
@MikeMcC399 MikeMcC399 force-pushed the yarn-classic-corepack branch from 9c0fffd to f028815 Compare October 31, 2023 06:53
@MikeMcC399 MikeMcC399 changed the title tests: set yarn classic example as corepack compatible tests: set yarn classic examples as corepack compatible Oct 31, 2023
@emilyrohrbough
Copy link
Member

Are you experiencing issues running these examples with the latest version of yarn? I think it'd be worth updating those examples if needed.

This change seems to adds unnecessary maintenance this repo for an experimental feature that may change at some point. I think users leveraging experimental features can expect repositories they are not owning may not work with corepack. I think this would be a great add once corepack lands as a fully supported feature.

@MikeMcC399
Copy link
Collaborator Author

MikeMcC399 commented Nov 1, 2023

@emilyrohrbough

Nobody has reported issues so far with corepack, so I think it's OK to put this suggestion on the backburner.

This is one of several challenges to support Yarn.

  • Yarn Classic was frozen a year ago (no more bug fixes or enhancements) so it is effectively unsupported
  • The preferred and default modes for the follow-on Yarn Modern involve multiple experimental features (corepack, "ESM support for PnP uses the experimental loader API and is therefore experimental") and this is not compatible with Cypress Component Testing.

This leaves Yarn users slightly in limbo. Cypress and Yarn Modern work best without corepack and in nodeLinker: node-modules mode.

The pnpm documentation also describes Using corepack.

Related repos

@MikeMcC399 MikeMcC399 deleted the yarn-classic-corepack branch November 1, 2023 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants