rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] Rush update fails during linking step

Open WebEferen opened this issue 3 years ago • 9 comments

Summary

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

Repro steps

  • Add two projects into rush workspace (project A, project B)
  • Add inside both package.json(s) dependencies which are using npm alias (ideally alias scoped package as non-scoped or otherwise) and ideally they should be exactly the same ones
  • Run rush update (or rush link)

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 avatar Jan 13 '23 14:01 WebEferen

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.

WebEferen avatar Jan 13 '23 15:01 WebEferen

Which package manager are you using? Is useWorkspaces enabled?

iclanton avatar Jan 18 '23 19:01 iclanton

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

WebEferen avatar Jan 18 '23 21:01 WebEferen

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

freedyc avatar Jul 25 '23 11:07 freedyc

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

MadhuPG avatar Jul 26 '23 15:07 MadhuPG

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

package.json contains [email protected] which causes this error

freedyc avatar Aug 05 '23 14:08 freedyc

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.)

octogonz avatar Aug 05 '23 21:08 octogonz

same...

cqcmdwym avatar Nov 07 '23 14:11 cqcmdwym

This is still an issue.

Also, the lerna connection is not a connection. I don't have a lerna dependency or sub-dependency.

DigitalKrony avatar Mar 12 '25 17:03 DigitalKrony