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. #1206

Closed
2 of 5 tasks
jpbnetley opened this issue Jan 24, 2025 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@jpbnetley
Copy link

Description:
When corepack is enabled with the new version of yarn 4 (in my case [email protected]).
The action specifies the following:

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": "[email protected]". 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": "[email protected]". 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.

Action version:
v4

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

  • N/A

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

Expected behavior:
Expect the action to fail, but the link to yarn corepack should be correct https://yarnpkg.com/corepack

Actual behavior:
The link to the yarn corepack docs is incorrect, as it includes a full stop in the url https://yarnpkg.com/corepack.

@jpbnetley jpbnetley added bug Something isn't working needs triage labels Jan 24, 2025
@priya-kinthali
Copy link

Hello @jpbnetley 👋,
Thank you for reporting this issue. We will investigate it and get back to you as soon as we have some feedback.

@gowridurgad gowridurgad self-assigned this Jan 28, 2025
@joe-morel
Copy link

Hello @jpbnetley

Something similar recently happened to me.

By mistake, I upgraded to Yarn 4.6.0 and tried everything to downgrade to version 1.22.22, but I encountered this issue in all my projects.

To mitigate the problem, I made sure to delete all traces of Yarn on my Mac and reinstall version 1.22.22. However, the following error persisted:

Image

This project's package.json defines "packageManager": "[email protected]". However, the current global version of Yarn is 1.22.22.

Solution:

After doing some research on https://nodejs.org/api/corepack.html, I tried running the following command in the Mac terminal:

corepack use [email protected]

That solved my problem 👍🏽 ✅

I hope this helps! If anyone has an explanation for this, feel free to share it here.

@joe-morel
Copy link

Hello @jpbnetley

Something similar recently happened to me.

By mistake, I upgraded to Yarn 4.6.0 and tried everything to downgrade to version 1.22.22, but I encountered this issue in all my projects.

To mitigate the problem, I made sure to delete all traces of Yarn on my Mac and reinstall version 1.22.22. However, the following error persisted:
Image

This project's package.json defines "packageManager": "[email protected]". However, the current global version of Yarn is 1.22.22.

Solution:

After doing some research on https://nodejs.org/api/corepack.html, I tried running the following command in the Mac terminal:

corepack use [email protected]

That solved my problem 👍🏽 ✅

I hope this helps! If anyone has an explanation for this, feel free to share it here.

Corepack is a tool in Node.js that was introduced in version 16.9. It allows managing versions of package managers like Yarn and Pnpm without needing to install them globally.

In my case, I had also mistakenly enabled Corepack for [email protected].

I tested disabling Corepack, but then "yarn" was not recognized, so I proceeded to install it globally with npm to avoid relying on Corepack for now.

Not using Corepack was a personal decision for the moment; it doesn’t mean it’s good or bad.

The mistake I made was a bad practice due to my lack of knowledge about these new features.

Always keep in mind which version of Yarn is being enabled when you activate Corepack.

@gowridurgad
Copy link

Hi @jpbnetley, Thank you for bringing this to our attention. The issue you reported regarding the incorrect URL in the error message is not related to the setup-node action itself. Please create an issue in the Yarn repository to address this problem. If you need assistance with anything specific to setup-node, feel free to let us know.

@jpbnetley
Copy link
Author

Hi @gowridurgad, thank you for getting back to me.
I will create the issue on the yarn repository.

I'll close this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants