actions / actions/setup-node

If `cache: yarn` is specified, this action fails

Open
#1,027 10 comments 38 reactions 1 assignee View on GitHub

@v-mahabaleshwars is already working on this.

Since May 23, 2024.

bug
Dominant language
TypeScript
Stars
5k
Forks
1.7k
Avg merge
3d 12h
Merged PRs (30d)
2

Description

Description:
If I set packageManager property in package.json and set cache: yarn in this action, this action will fail.

Related:

Action version:
v4 (v4.0.2)

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

  • yarn 4.1.1

Repro steps:
This is the workflow that reproduced this issue with the minimum configuration.
https://github.com/esperecyan/actions-setup-node-debug/actions/runs/8907795048/workflow
You can confirm that the issue does not occur in the following cases:

  • If I set npm to packageManager.
  • If I set yarn to packageManager and do not set cache: yarn for this action.

Expected behavior:
actions/setup-node succeeds.

Actual behavior:
actions/setup-node fails with the following error.

Error: error This project's package.json defines "packageManager": "yarn@4.1.1". 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.
https://github.com/esperecyan/actions-setup-node-debug/actions/runs/8907795048/job/24462266566

Running corepack enable before actions/setup-node will avoid this issue.
https://github.com/esperecyan/actions-setup-node-debug/actions/runs/8907795048/job/24462266822

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.