yarnpkg / yarnpkg/berry

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

Open
#4,591 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug node-modules upholded
Dominant language
TypeScript
Stars
8.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Self-service
  • I'd be willing to implement a fix
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

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

Start with the reproduction repository at avaly/yarn-v3-bin-link-bug and inspect its package.json dependency combination. Reproduce the install with Yarn 3.2.1, then trace how node_modules/.bin/tsc is linked when TypeScript 4.7.4 and 3.9.10 are both present. Done means the reproduction links tsc to the expected 4.7.4 version while cdk8s-cli remains installed.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.