yarnpkg / berry

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

[Bug]: Wrong version linked in `node_modules/.bin` #4591

Open avaly opened 2 years ago

avaly commented 2 years ago

Self-service

Describe the bug

The wrong version of a dependency X is linked in node_modules/.bin/, but only when in combination with another package, which has a different version of the dependency X in its transitive dependency tree.

To reproduce

Reproduction repository: https://github.com/avaly/yarn-v3-bin-link-bug

The expected version of node_modules/.bin/tsc is 4.7.4.

However when also installing the cdk8s-cli package, yarn links tsc to version 3.9.10.

If you remove the cdk8s-cli dependency in package.json, then tsc is linked correctly to 4.7.4.

Environment

System:
  OS: Linux 5.13 Ubuntu 20.04.4 LTS (Focal Fossa)
  CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
Binaries:
  Node: 18.0.0 - /tmp/xfs-b91ff550/node
  Yarn: 3.2.1 - /tmp/xfs-b91ff550/yarn
  npm: 8.1.4 - ~/.volta/tools/image/npm/8.1.4/bin/npm

Additional context

No response

larixer commented 2 years ago

Additional information. This happens, because there is also a package named typescript-3.9 which get hoisted to the top-level and which exports tsc bin entry, it is an aliased package. So typescript and typescript-3.9 race for the .bin entry.