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

docs: The url to the yarn corepack documentation is not found (invalid url) when corepack is enabled for the repo, but not the action. #9182

Open
jpbnetley opened this issue Jan 30, 2025 · 5 comments

Comments

@jpbnetley
Copy link

Originally I filed this bug under setup node: actions/setup-node#1206 (comment)
But it was pointed out that the message was a yarn specific error message.

In summary:
The project was migrated to yarn berry (in my case yarn@4.6.0)
I have a Github action setup that tries to build the project when core pack is not yet enabled.

The following error is presented when the Github action tries to run the setup node.

Run actions/setup-node@v4
Found in cache @ /opt/hostedtoolcache/node/20.18.1/x64
Environment details
/usr/local/bin/yarn --version
1.22.22
/usr/local/bin/yarn cache dir
error This project's package.json defines "packageManager": "yarn@4.6.0". However the current global version of Yarn is 1.22.22.

Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from [16](https://github.com/AlbatrosEng/a9-cwi-client/actions/runs/12948571237/job/36117499630?pr=172#step:3:18).9 and 14.19.
Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.
Error: error This project's package.json defines "packageManager": "yarn@4.6.0". However the current global version of Yarn is 1.22.22.

Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.[19](https://github.com/AlbatrosEng/a9-cwi-client/actions/runs/12948571237/job/36117499630?pr=172#step:3:21).
Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.

I noticed that the link provided in the error is not found, because it includes a full stop.
The link should be https://yarnpkg.com/corepack and not https://yarnpkg.com/corepack.

To reproduce

Repro steps:
I used the migration docs here to upgrade from yarn 1 to the new version.
But I think it can be re-produced with the following:

  • create a repo with yarn.
  • Then enable corepack for yarn corepack enable
  • Update yarn to the latest with yarn set version berry
  • And then let the github action run
    The action I use as an example:
  name: Code Validation

on:
  workflow_call:

env:
  node_version: 20

jobs:
  tests:
    name: Test
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v4

    - name: Use Node.js ${{ env.node_version }}
      uses: actions/setup-node@v4
      with:
        node-version: ${{ env.node_version }}
        cache: 'yarn'

    - uses: actions/cache@v4
      id: npm-cache
      with:
        path: node_modules
        key: ${{ runner.os }}-${{ env.node_version }}-node-${{ hashFiles('**/yarn.lock') }}
        restore-keys: ${{ runner.os }}-${{ env.node_version }}-node-
      
    - name: Install    
      if: steps.npm-cache.outputs.cache-hit != 'true'  
      run: yarn
@MikeMcC399
Copy link

MikeMcC399 commented Mar 2, 2025

@jpbnetley

If you run the following

cd $(mktemp -d)
corepack enable yarn
corepack use yarn
corepack disable yarn
npm install yarn@1.22.22 -g
yarn cache dir

in a local Ubuntu terminal window you will see the error message with the URL

https://yarnpkg.com/corepack

highlighted in blue.

Image

or as text:


error This project's package.json defines "packageManager": "yarn@4.7.0". However the current global version of Yarn is 1.22.22.

Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.


You can right-click on it, select OpenLink and the website is opened in a browser window. You can also click on the above text when it is interpreted by Markdown and it will open correctly.

Your problem occurs if you copy the text from a CI log file and you copy also the full stop (period) at the end of the sentence together with the URL.

The sentence could be made less susceptible to this issue if it were rearranged as

"Check out https://yarnpkg.com/corepack for more information."

In that case there would be spaces either side of the URL to make it easier to copy.

I can't however see where this text is coming from although it is in the final build of Yarn 1.22.22 and this version is frozen, so I wouldn't expect the maintainers to change the text.

@MikeMcC399
Copy link

@jpbnetley

You've probably solved this by now, but in case anybody else is reading this: In order to fix the workflow you will need to add:

- run: corepack enable yarn

before you call actions/setup-node@v4 with Yarn caching enabled. Unfortunately setup-node is not aware of corepack.

@jpbnetley
Copy link
Author

Hi @MikeMcC399
Thank you for taking the time to answer 😄

yes, the actually error I had is solved.
I found an article online and implemented as follows

- name: Setup target Node.js to enable Corepack
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.node_version }}
 - run: corepack enable

 - uses: actions/setup-node@v4
        with:
          node-version: ${{ env.node_version }}

But the issue I open was just that the url mentioned in the error is invalid.
Particular the last sentence
check out https://yarnpkg.com/corepack.
Where that redirects to https://yarnpkg.com/corepack.
but it should redirect with out the full stop.
https://yarnpkg.com/corepack
The issue is to bring attention to the issue I discovered 😄

@MikeMcC399
Copy link

@jpbnetley

I looked at the URL in the error message in #9182 (comment) and I made a suggestion to improve it.

It's possible that the maintainers may be reading this and that they might make a change, however officially Yarn v1 Classic has been frozen for quite some time.

@jpbnetley
Copy link
Author

Thanks @MikeMcC399.
Yes I thought because it is frozen, it might not be updated.
But at least it might serve as a helpful resource for others.

Thanks for taking the time to go thought the issue and providing helpful feedback ❤

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

No branches or pull requests

2 participants