nodejs / nodejs/corepack

`corepack enable` exits successfully (exit code 0), but isn't actually enabled

Open
#507 5 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
279
Avg merge
1h 47m
Merged PRs (30d)
2

Description

Issue

@Tobbe ➜ /workspaces/redwood (main) $ yarn -v
1.22.22
@Tobbe ➜ /workspaces/redwood (main) $ yarn
error This project's package.json defines "packageManager": "yarn@4.3.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.
@Tobbe ➜ /workspaces/redwood (main) $ corepack enable
@Tobbe ➜ /workspaces/redwood (main) $ yarn
error This project's package.json defines "packageManager": "yarn@4.3.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.
@Tobbe ➜ /workspaces/redwood (main) $ corepack prepare
Preparing yarn@4.3.0...
@Tobbe ➜ /workspaces/redwood (main) $ yarn -v
1.22.22
@Tobbe ➜ /workspaces/redwood (main) $ corepack install -g yarn@latest
Installing yarn@4.3.1...
@Tobbe ➜ /workspaces/redwood (main) $ yarn -v
1.22.22
@Tobbe ➜ /workspaces/redwood (main) $ yarn
error This project's package.json defines "packageManager": "yarn@4.3.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.

Every command (except running just yarn) above exited with code 0. But none of them seems to actually do anything.

Expected behavior

Ideally corepack enable would work, and yarn would switch to version 4.3, but at the very least some kind of error message would be useful when corepack can't actually be enabled.

Additional Info

corepack yarn -v correctly prints out 4.3.0

Reproduction

  1. Go to https://github.com/redwoodjs/redwood
  2. Press . on your keyboard to open the redwood repo in an in-browser editor
  3. Set up a new codespace
  4. In the terminal, run corepack enable and yarn install

Workaround

Always use corepack yarn instead of just yarn

Contributor guide

Open the contributing guide

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.

Research direction

Reproduce the codespace scenario from the issue, starting with corepack enable, yarn -v, and corepack yarn -v. Trace the corepack enable entry point and compare its behavior with the working corepack yarn path; done means the command either activates the expected Yarn version or reports why it cannot.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.