You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, due to how they are aggregated, yarn explain peer-requirements says peer requests cannot be all satisfied when they can.
Consider this dependency tree:
A --> X ==> P@^2
--> P@1.0.0
B --> Y ==> P@^3
--> P@1.0.0
where A and B are workspaces , --> represents a regular dependency, and ==> represents a peer dependency.
When we install this, we get an peer warning, which, when explained, gives
$ yarn explain peer-requirements p6ab7e
We have a problem with p, which is provided with version 1.0.0.
It is needed by the following direct dependencies of workspaces in your project:
✘ x@npm:1.0.0 [0f866] (via ^2)
✘ y@npm:1.0.0 [10ea6] (via ^3)
Unfortunately, put together, we found no single range that can satisfy all those peer requirements.
Your best option may be to try to upgrade some dependencies with yarn up, or silence the warning via logFilters.
However, this advice is not correct as it is easily fixable by making a and b depend on different versions of p.
This is caused by how peer warnings are aggregated by the provided package which loses information on different packages that depend on it. Peer warnings should instead be aggregated by requestee + peer request ident which are the individual knobs that the end user can turn.
To reproduce
constfs=require(`node:fs/promises`);constp=require(`node:path`);asyncfunctionmakeWorkspace(path,manifest){awaitfs.mkdir(path);awaitfs.writeFile(p.join(path,`package.json`),JSON.stringify(manifest));}awaitmakeWorkspace(`./package-x`,{name: `x`,version: `1.0.0`,peerDependencies: {p: `^2`,},});awaitmakeWorkspace(`./package-y`,{name: `y`,version: `1.0.0`,peerDependencies: {p: `^3`,},});awaitmakeWorkspace(`./package-p`,{name: `p`,version: `1.0.0`,});awaitmakeWorkspace(`./workspace-a`,{name: `a`,version: `1.0.0`,dependencies: {x: `1.0.0`,p: `1.0.0`,},});awaitmakeWorkspace(`./workspace-b`,{name: `b`,version: `1.0.0`,dependencies: {y: `1.0.0`,p: `1.0.0`,},});constoutput=awaitpackageJsonAndInstall({workspaces: [`workspace-*`,`package-*`,],});consthash=output.match(/\(p[0-9a-f]{5}\)/)[0].slice(1,-1);awaitexpect(yarn('explain','peer-requirements',hash)).resolves.not.toMatch(/no single range that can satisfy all/);
Error: expect(received).resolves.not.toMatch(expected)
Expected pattern: not /no single range that can satisfy all/
Received string: "We have a problem with p, which is provided with version 0.0.0-use.local.
It is needed by the following direct dependencies of workspaces in your project:
✘ x@workspace:package-x [f8fd9] (via ^2)
✘ y@workspace:package-y [b18b8] (via ^3)
Unfortunately, put together, we found no single range that can satisfy all those peer requirements.
Your best option may be to try to upgrade some dependencies with yarn up, or silence the warning via logFilters.
"
at Object.toMatch (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-9b3e8262b0.zip/node_modules/expect/build/index.js:202:20)
at module.exports (evalmachine.<anonymous>:54:71)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-69609f7d06.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:57:13
at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-69609f7d06.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:18:16)
at async executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-69609f7d06.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:25:12)
at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-69609f7d06.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:26:38)
at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-312910c71e.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-312910c71e.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-312910c71e.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)
Self-service
Describe the bug
Sometimes, due to how they are aggregated,
yarn explain peer-requirements
says peer requests cannot be all satisfied when they can.Consider this dependency tree:
where
A
andB
are workspaces ,-->
represents a regular dependency, and==>
represents a peer dependency.When we install this, we get an peer warning, which, when explained, gives
However, this advice is not correct as it is easily fixable by making
a
andb
depend on different versions ofp
.This is caused by how peer warnings are aggregated by the provided package which loses information on different packages that depend on it. Peer warnings should instead be aggregated by requestee + peer request ident which are the individual knobs that the end user can turn.
To reproduce
Environment
Additional context
No response
The text was updated successfully, but these errors were encountered: