yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.23k stars 1.07k forks source link

[Bug?]: Install instructions install 1.x instead of 3.x+ #6274

Closed dylanh724 closed 4 days ago

dylanh724 commented 1 month ago

Self-service

Describe the bug

https://yarnpkg.com/getting-started/install

These instructions are the same as the classic instructions, more or less, resulting in v 1.22.11 (which isn't even the classic stable version)

To reproduce

With node 20.12.2 (lts):

  1. corepack enable
  2. yarn -v

Environment

> yarn dlx -q envinfo --preset jest

yarn run v1.22.11
warning package.json: No license field
error Command "dlx" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additional context

The installation process to get to the correct latest stable version (3.x?) is wildly confusing with inaccurate best-practice installation steps. I tried to go to the Discord for help, but your website Discord link was also broken. Perhaps this hasn't been updated since 1.x?

clemyan commented 1 month ago

resulting in v 1.22.11 (which isn't even the classic stable version)

This should not happen if Corepack is properly enabled unless

The Corepack version that comes with Node 20.12.2 should be Corepack 0.25.2, which default to yarn v1.22.21.

Check your PATH or use which yarn (or equivalent on your system) to make sure your yarn command is the shim generated by Corepack.

yarn dlx -q envinfo --preset jest

yarn run v1.22.11

Also should not happen if Corepack is properly enabled

dylanh724 commented 1 month ago

resulting in v 1.22.11 (which isn't even the classic stable version)

This should not happen if Corepack is properly enabled unless

  • Your working directory is inside a project with a pinned yarn version
  • You somehow installed an old Corepack version

The Corepack version that comes with Node 20.12.2 should be Corepack 0.25.2, which default to yarn v1.22.21.

Check your PATH or use which yarn (or equivalent on your system) to make sure your yarn command is the shim generated by Corepack.

yarn dlx -q envinfo --preset jest

yarn run v1.22.11

Also should not happen if Corepack is properly enabled

Hmm, please define "properly" - from my understanding, it's just 1 command (above)?

I'm on a fresh install of Win11, installed Node via nvm, installed node 20 and activated via nvm, then issues the corepack enable command.

Does yarn have known issues with nvm?

clemyan commented 1 month ago

Looking at it again, I think the most likely scenario is you have a pinned version of yarn. Try yarn --version again. If it still shows v1.22.11, look for a package.json file and see if there is a packageManager field.


Let's try this then

  1. Make sure you are on the correct versions of Node and Corepack, and an unexpected version of Yarn
> node -v
v20.12.2
> corepack -v
0.25.2
> yarn -v
1.22.11
  1. Check where your yarn command points to. That would be where yarn for CMD or Get-Command yarn for PowerShell. Make sure that is in the same directory as your node command. If not then you have installed yarn outside of Corepack and that is interfering with Corepack.
> Get-Command yarn

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
ExternalScript  yarn.ps1                                                      C:\Program Files\nodejs\yarn.ps1

> Get-Command node

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     node.exe                                           20.12.2.0  C:\Program Files\nodejs\node.exe
  1. Run yarn config get yarnPath to check if you are inside a project with a pinned yarn binary. If that outputs a path then that is the pinned yarn binary.
Gambitboy commented 1 month ago

Not sure if its related but I'm having the reverse of this.

I opened an issue on the original repo

When I try install yarn v1 via NPM or Brew I get version 3.6.4

This is on a M1 Mac

Gambitboy commented 1 month ago

I fixed it by running the following command:

rm -rf ~/.yarn*

Suggested by someone on stackoverflow. Might be useful here. https://stackoverflow.com/a/70978316/11701253

Not really sure how berry got installed on my machine as I've never used it before.

dylanh724 commented 1 month ago

Just on my phone, but I'll be able to test this soon -- perhaps in a few days. Cheers for advice.

yarnbot commented 1 week ago

Hi! 👋

It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it.