setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

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

Open esperecyan opened this issue 9 months ago • 4 comments

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

Related:

  • https://github.com/actions/setup-node/issues/531#issuecomment-1816774699

Action version: v4 (v4.0.2)

Platform:

  • [x] Ubuntu
  • [ ] macOS
  • [ ] Windows

Runner type:

  • [x] 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": "[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. 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

esperecyan avatar May 01 '24 11:05 esperecyan

Hello @esperecyan Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

HarithaVattikuti avatar May 01 '24 19:05 HarithaVattikuti

Hitting this today too.

1kevgriff avatar May 10 '24 14:05 1kevgriff

#901 #546 #480

n0099 avatar Jun 10 '24 21:06 n0099

Running corepack enable before actions/setup-node will avoid this issue.

works only for node 18+

for node 14-16 see https://github.com/actions/setup-node/issues/1075#issuecomment-2165643488

SunsetTechuila avatar Jun 13 '24 13:06 SunsetTechuila