[Bug?]: A list of negated os/cpu/libc values matches every platform

Open Beginner friendly
#7,351 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
nodejs, typescript
Domain
tooling

Research direction

Start in packages/yarnpkg-core/sources/Manifest.ts at toConditionLine (around lines 1017-1023), where all tokens are joined with |; trace how negated os/cpu/libc entries are turned into tokens. Reproduce with the linked repro's yarn install and yarn run check, then compare with npm, which skips the package when any negated value matches. Done means the generated condition no longer matches every platform for a list like !arm, !x64, covered by a core unit test.

Written by the indexing model from the issue text.

Description

bug
Self-service
  • I'd be willing to implement a fix
Describe the bug

For "cpu": ["!arm", "!arm64", "!riscv64", "!x64"], Yarn writes:

conditions: (!cpu=arm | !cpu=arm64 | !cpu=riscv64 | !cpu=x64)

At least one term is always true, so the package installs on every platform. npm rejects a package if any negated value matches, and skips it.

Cause: toConditionLine joins all tokens with |: https://github.com/yarnpkg/berry/blob/cfa40bda203d1b0a8cc25886af19bc11b670ef84/packages/yarnpkg-core/sources/Manifest.ts#L1017-L1023

Impact: sass-embedded's fallback packages (sass-embedded-all-unknown, sass-embedded-unknown-all) install everywhere with Yarn, adding sass, chokidar and `@parcel/watcher.

To reproduce

Repro: https://github.com/marcalexiei/yarn-negated-conditions-repro

Its only dependency is the optional [email protected]:

yarn install
yarn run check

Expected: the package is skipped, as with npm.
Actual: it's installed, and the check fails:

FAIL darwin-arm64: sass-embedded-all-unknown is installed, but its cpu field excludes arm64

CI runs the check with Yarn and npm on multiple OS.
The Yarn jobs fail and the npm jobs pass: https://github.com/marcalexiei/yarn-negated-conditions-repro/actions/runs/45340412493

Environment
System:
  OS: macOS 27.2.1
  CPU: (8) arm64 Apple M3
Binaries:
  Node: 24.22.3
  Yarn: 4.19.0
  npm: 11.19.1
Additional context

Related: #5962 (about evaluating negated conditions against supportedArchitectures, not about generating them).

Dominant language
TypeScript
Stars
8.1k
Forks
1.4k
Avg merge
2d 1h
Merged PRs (30d)
4

Getting set up

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.

More from yarnpkg/berry

All issues in yarnpkg/berry

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.