Problem/Motivation

Since 13 Sep 2022 we've recommended using corepack to manage which yarn version but using this results in changing core/package.json when you run a yarn command which is frustrating.

Steps to reproduce

Use corepack to manage yarn and run a yarn command in /core

Proposed resolution

Add the missing packageManager key.

Remaining tasks

User interface changes

N/a

API changes

N/a

Data model changes

N/a

Release notes snippet

N/a

Issue fork drupal-3428122

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexpott created an issue. See original summary.

alexpott’s picture

This is even more important when corepack becomes manadatory for developing on multiple core branches following #3109556: Update from Yarn 1 to Yarn 4

alexpott’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Reviewed & tested by the community

While I couldn't reproduce this locally (I am on an older NodeJS/corepack setup than Alex) I think this is a good idea:

  • Yarn will apparently warn if packageManager is set but corepack is not enabled, which will help users get it installed locally.
  • Once corepack is enabled it means everyone will use the specified version of yarn locally.
alexpott’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committing because I cannot commit to Drupal until this is merged... lol

Committed and pushed ef8b6e30b8 to 11.x and 2c9040ee8f to 10.3.x and c13f63ce92 to 10.2.x. Thanks!

  • alexpott committed c13f63ce on 10.2.x
    Issue #3428122 by alexpott, longwave: Add packageManager key to core/...

  • alexpott committed 2c9040ee on 10.3.x
    Issue #3428122 by alexpott, longwave: Add packageManager key to core/...

  • alexpott committed ef8b6e30 on 11.x
    Issue #3428122 by alexpott, longwave: Add packageManager key to core/...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

xjm’s picture

Status: Closed (fixed) » Needs work
Issue tags: +Needs change record, +Needs documentation updates

This broke my commit workflow and unfortunately took a bit of head-desking to figure out what was going on; I spent quite a bit of time tearing apart and rebuilding my toolchain before I understood the problem. From the yarn page about corepack:

DANGER
Some third-party distributors may not include Corepack by default, in particular if you install Node.js from your system package manager. If that happens, running npm install -g corepack before corepack enable should do the trick.

I think this needs a change record and probably a handbook page update somewhere. I already updated https://github.com/alexpott/d8githooks/blob/main/README.md but that's not what 99.99% of people using core's build tooling locally will reference. :)

xjm’s picture

In terms of change records we can probably just add to the main Yarn 4 one at https://www.drupal.org/node/3428571; doing that now.

xjm’s picture

Issue tags: -Needs change record

Updated the CR; still needs to go in the handbook setup instructions somewhere though.

quietone’s picture

Status: Needs work » Fixed

This was include in Frontend Developer tools for Drupal core in Sep 2022. I searched the Drupal wiki for other places this information needed to be included and could not find any other suitable page.

Therefor I am going to restore the fixed status. If someone has a better idea, re-open and add a comment.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

xjm’s picture

Amending attribution, and also crediting @quietone for the docs info.