microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.85k stars 594 forks source link

[rush] Rush update fails during linking step #3893

Open WebEferen opened 1 year ago

WebEferen commented 1 year ago

Summary

Rush update fails during linking process. It prints error: ERROR: Child already exists: (package-name)

Repro steps

Use npm alias with scoped packages in both applications: "package-name": "npm:@scoped/package-name@latest"

Expected result: Packages will be linked correctly

Actual result: ERROR: Child already exists (package-name)

Details

During migration into rush, several packages were moved and they were working fine. Two of the migrated packages contains the same npm aliases (let's call it package-name). With those packages migrated, rush update stopped working after shrinkwrap step (packages without npm links were linked successfully but the ones with aliases failed.

Found similar issues here: https://github.com/microsoft/rushstack/issues/1279 (two last comments)

The line which is throwing error is attached below. My assumption is that the applied logic is wrong and when we spot that the package already exists, we should return without throwing error as it is right now in normally listed packages.

https://github.com/microsoft/rushstack/blob/2c1ffc5b40ad2164fe147aef65d0f348778e8a3a/libraries/rush-lib/src/logic/base/BasePackage.ts#L190

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.88.0
rushVersion from rush.json? 5.88.0
useWorkspaces from rush.json?
Operating system? Mac
Would you consider contributing a PR? Not sure
Node.js version (node -v)? 18.13.0
WebEferen commented 1 year ago

Turns out that commenting this line and applying diff allows usage of multiple the same aliases because the implementation is based on Map (so anyway it won't have a duplicate) - will open a PR with such change.

iclanton commented 1 year ago

Which package manager are you using? Is useWorkspaces enabled?

WebEferen commented 1 year ago

@iclanton useWorkspaces is not enabled. I was using npm (version 9.2.x)

freedyc commented 1 year ago

It happened to me, too. When will it be fixed

MadhuPG commented 1 year ago

Turns out that commenting this line and applying diff allows usage of multiple the same aliases because the implementation is based on Map (so anyway it won't have a duplicate) - will open a PR with such change.

Were you able to raise that PR? I am facing the same issue, and am not able to proceed. Is there any way that these changes can be reflected sooner? Using rush 5.100.1, yarn: 1.22.4, node: 18.17.0; Error is: Child already exists: string-width

freedyc commented 1 year ago

It happened to me, too. When will it be fixed

package.json contains lerna@5.1.4 which causes this error

octogonz commented 1 year ago

We no longer actively maintain the code path for useWorkspaces=false, because the Rush maintainers' monorepos are all using useWorkspaces=true now.

Is there a reason why you can't switch to useWorkspaces=true? It is a better design that eliminates a lot of problems.

(Of course if someone wants to contribute a PR to improve the useWorkspaces=false behavior, that would be great.)

cqcmdwym commented 11 months ago

same...