Describe the bug
"dependencies": {
"lib1": "npm:lodash@^4.17.15",
"lib2": "npm:lodash@^4.17.15"
}
"dependencies": {
"lib1": "npm:@testing-library/[email protected]",
"lib2": "npm:@testing-library/[email protected]"
}
$ yarn
➤ YN0000: ┌ Resolution step
➤ YN0002: │ test@workspace:. doesn't provide react@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ test@workspace:. doesn't provide react-dom@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ test@workspace:. doesn't provide react@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ test@workspace:. doesn't provide react-dom@* requested by @testing-library/react@npm:10.0.4
➤ YN0000: └ Completed in 4.51s
➤ YN0000: ┌ Fetch step
➤ YN0001: │ Error: Assertion failed: The locator should have been registered
at /Users/brek/nw/ut/.yarn/releases/yarn-berry.js:42:113324
at /Users/brek/nw/ut/.yarn/releases/yarn-berry.js:10:124068
at Array.map (<anonymous>)
at Object.t.sortMap (/Users/brek/nw/ut/.yarn/releases/yarn-berry.js:10:124061)
at T.fetchEverything (/Users/brek/nw/ut/.yarn/releases/yarn-berry.js:42:113232)
at /Users/brek/nw/ut/.yarn/releases/yarn-berry.js:42:123586
at f.startTimerPromise (/Users/brek/nw/ut/.yarn/releases/yarn-berry.js:16:57282)
at T.install (/Users/brek/nw/ut/.yarn/releases/yarn-berry.js:42:123534)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /Users/brek/nw/ut/.yarn/releases/yarn-berry.js:50:37069
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 4.52s
md5-250d1923b60557b4bc54496e40cd1f56
**Repro**
```js repro
const installPromise = packageJsonAndInstall({
dependencies: {
"lib1": "npm:@testing-library/[email protected]",
"lib2": "npm:@testing-library/[email protected]"
}
});
await expect(installPromise)
.resolves.toBeTruthy();
Environment if relevant (please complete the following information):
Not to argue if this is a bug or not, but just out of curiosity...
But I'm wondering in what use case you would have two different aliases to the exact same version of another package in the your own package?
It is just part of release cycle. I want to have a bundle with two versions on package, stable and current and switch between them in runtime.
For example, during development i have something like this
"dependencies": {
"calc-stable": "npm:@private/[email protected]",
"calc": "npm:@private/[email protected]"
}
when release comes, I want to change version of stable package
"dependencies": {
"calc-stable": "npm:@private/[email protected]",
"calc": "npm:@private/[email protected]"
}
This issue reproduces on master:
Error: expect(received).resolves.toBeTruthy()
Received promise rejected instead of resolved
Rejected to value: [Error: Command failed: /usr/bin/node /github/workspace/scripts/actions/../run-yarn.js install
➤ YN0000: ┌ Resolution step
::group::Resolution step
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react-dom@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react-dom@* requested by @testing-library/react@npm:10.0.4
::endgroup::
➤ YN0000: └ Completed in 1.8s
➤ YN0000: ┌ Fetch step
::group::Fetch step
➤ YN0001: │ Error: Assertion failed: The locator should have been registered
at /github/workspace/packages/yarnpkg-core/sources/Project.ts:946:15
at mapper (/github/workspace/packages/yarnpkg-core/sources/miscUtils.ts:239:43)
at Array.map (<anonymous>)
at Object.map [as sortMap] (/github/workspace/packages/yarnpkg-core/sources/miscUtils.ts:239:30)
at Project.sortMap [as fetchEverything] (/github/workspace/packages/yarnpkg-core/sources/Project.ts:943:37)
at fetchEverything (/github/workspace/packages/yarnpkg-core/sources/Project.ts:1470:18)
at StreamReport.cb [as startTimerPromise] (/github/workspace/packages/yarnpkg-core/sources/StreamReport.ts:198:20)
at Project.startTimerPromise [as install] (/github/workspace/packages/yarnpkg-core/sources/Project.ts:1469:23)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
::endgroup::
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 1.83s
]
at expect (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-0ac41999f0.zip/node_modules/expect/build/index.js:138:15)
at module.exports (evalmachine.<anonymous>:9:7)
at /github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:19
at executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:22)
at Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:18)
at ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:59)
at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.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-a57989414f.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-a57989414f.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)
I've managed to isolate this to packages with peer dependencies. It works to alias the same version of lodash multiple times because it doesn't have any peer dependencies, unlike @testing-library/react. It looks like the virtual package created for @testing-library/react gets lost when it's aliased multiple times, I'll investigate.
This issue reproduces on master:
Error: expect(received).resolves.toBeTruthy()
Received promise rejected instead of resolved
Rejected to value: [Error: Command failed: /usr/bin/node /github/workspace/scripts/actions/../run-yarn.js install
➤ YN0000: ┌ Resolution step
::group::Resolution step
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react-dom@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react-dom@* requested by @testing-library/react@npm:10.0.4
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide react@* requested by @testing-library/react@npm:10.0.4
::endgroup::
➤ YN0000: └ Completed in 1.84s
➤ YN0000: ┌ Fetch step
::group::Fetch step
➤ YN0001: │ Error: Assertion failed: The locator should have been registered
at mapper (/github/workspace/packages/yarnpkg-core/sources/Project.ts:990:21)
at map (/github/workspace/packages/yarnpkg-core/sources/miscUtils.ts:243:43)
at Array.map (<anonymous>)
at Object.sortMap (/github/workspace/packages/yarnpkg-core/sources/miscUtils.ts:243:30)
at Project.fetchEverything (/github/workspace/packages/yarnpkg-core/sources/Project.ts:986:19)
at cb (/github/workspace/packages/yarnpkg-core/sources/Project.ts:1529:18)
at StreamReport.startTimerPromise (/github/workspace/packages/yarnpkg-core/sources/StreamReport.ts:248:20)
at Project.install (/github/workspace/packages/yarnpkg-core/sources/Project.ts:1528:23)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
::endgroup::
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 1.87s
]
at expect (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-0ac41999f0.zip/node_modules/expect/build/index.js:138:15)
at module.exports (evalmachine.<anonymous>:9:7)
at /github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:19
at executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:22)
at Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:18)
at ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:59)
at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.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-a57989414f.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-a57989414f.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)