-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Self-service
- I'd be willing to implement a fix
Describe the bug
The dedupe command fails when a package is included as a dependency in 2+ locations in the dependency tree, but points to a different npm package in one of those dependency entries. Running dedupe under that condition produces the error:
Error: Assertion failed: The package (<checksum>) should have been registered
Consider this real-world example using the plotly.js package. plotly.js depends on the regl package, but they instead point it at their own fork, @plotly/regl. It also depends on the gl-text package, which in turn depends on regl as well; however, gl-text depends on the real regl package, not Plotly's fork. Here is a simplification of their dependencies:
plotly.js:
"dependencies": {
"gl-text": "^1.3.1",
"regl": "npm:@plotly/regl@^2.1.2"
}gl-text:
"dependencies": {
"regl": "^2.0.0"
}Because of this, any project that depends on plotly.js will also fail to dedupe.
To reproduce
The following example uses very small packages to demonstrate. [email protected] has a single dependency, parse-ms@^1.0.0. The error is caused by overriding parse-ms with any other package (I used parse-ms-js here, but it could be anything).
await packageJsonAndInstall({
devDependencies: {
[`pretty-ms`]: `3.2.0`,
[`parse-ms`]: `npm:[email protected]`
}
});
await expect(yarn(`dedupe`)).rejects.not.toThrow(`Command failed`);Produces the error:
➤ YN0000: ┌ Deduplication step
➤ YN0001: │ Error: Assertion failed: The package (5366fb423abc93e95bdb6398ba5fe3098b1300090b3c0e3ab69ae123da057cb49659ccabc63b49b9b5013feab4329c6902ed251af7ea55bfdc5c53b38f79f1d5) should have been registered
at /Users/mchill/test/.yarn/releases/yarn-berry.cjs:473:1519
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)
at async /Users/mchill/test/.yarn/releases/yarn-berry.cjs:473:2181
at async Je.startSectionPromise (/Users/mchill/test/.yarn/releases/yarn-berry.cjs:413:3303)
at async jN (/Users/mchill/test/.yarn/releases/yarn-berry.cjs:473:1983)
at async /Users/mchill/test/.yarn/releases/yarn-berry.cjs:473:3699
at async Function.start (/Users/mchill/test/.yarn/releases/yarn-berry.cjs:413:2373)
at async cm.execute (/Users/mchill/test/.yarn/releases/yarn-berry.cjs:473:3595)
at async cm.validateAndExecute (/Users/mchill/test/.yarn/releases/yarn-berry.cjs:349:673)
➤ YN0000: └ Completed
Environment
System:
OS: macOS 12.1
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 16.6.1 - /private/var/folders/bz/d128n_p52230mdth5c08hwf00000gn/T/xfs-4c23f2a9/node
Yarn: 3.2.0 - /private/var/folders/bz/d128n_p52230mdth5c08hwf00000gn/T/xfs-4c23f2a9/yarn
npm: 7.20.3 - ~/.nvm/usr/local/opt/nvm/nvm.sh/versions/node/v16.6.1/bin/npmAdditional context
No response