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

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

Open
Tobbe opened this issue Jul 2, 2024 · 2 comments

Comments

@Tobbe
Copy link

Tobbe commented Jul 2, 2024

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

@aduh95
Copy link
Contributor

aduh95 commented Jul 2, 2024

Is maybe yarn an alias? What does command -v yarn returns? What about alias yarn?

@Tobbe
Copy link
Author

Tobbe commented Jul 2, 2024

@Tobbe ➜ /workspaces/redwood (main) $ command -v yarn
/usr/bin/yarn
@Tobbe ➜ /workspaces/redwood (main) $ alias yarn
bash: alias: yarn: not found
@Tobbe ➜ /workspaces/redwood (main) $ realpath `which yarn`
/usr/local/share/nvm/versions/node/v20.14.0/lib/node_modules/corepack/dist/yarn.js
@Tobbe ➜ /workspaces/redwood (main) $ 

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