rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] Internal Error "Cannot find installed dependency" with PNPM 5

Open m4ss1m0g opened this issue 3 years ago • 11 comments

Summary

[rush] Using rush update twice raise

ERROR: Internal Error: Cannot find installed dependency "@nestjs/common" in "c:\xxx\node_modules" You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

Repro steps

  1. Download the attached solution rush-nest.zip
  2. run rush install
  3. run rush update

Details

The error raised says about the @nestjs/common package on data project which is the same installed on ui project. The objective is to write a custom service with @Injectable() attribute on a separate project.

Standard questions

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

Question Answer
@microsoft/rush globally installed version? 5.40.7
rushVersion from rush.json? 5.40.7
useWorkspaces from rush.json? false
Operating system? Windows
Would you consider contributing a PR? No
Node.js version (node -v)? v12.21.0

m4ss1m0g avatar Mar 09 '21 18:03 m4ss1m0g

This is a bug. I have seen it before. Having a repro is very helpful, thanks!

The rush update command performs a minimal update of your pnpm-lockfile.yaml to satisfy new package.json requirements for your projects. Developers prefer this minimal update because it avoids having to deal with potential breaks caused by new versions of dependencies that are unrelated to the work in their PR. However, if everyone always uses rush update, then eventually your pnpm-lockfile.yaml will incrementally become weirder and weirder until it no longer represents a typical clean installation. Then we encounter whatever obscure edge is causing this Rush bug.

The simple workaround is to run rush update --full, which will put you back into a normal pnpm-lockfile.yaml. I confirmed that this fixes your repro.

Ideally, someone should be running rush update --full regularly (weekly?) in your monorepo, maybe as its own PR so that versioning breaks can be handled in isolation. But from what I've seen, in an active repo this will happen by itself, because the people who are repo maintainers will come to prefer to always do rush update --full in their own PRs, because they are interested in catching these kinds of problems.

Another option is to enable useWorkspaces=true in rush.json, which I believe completely eliminates the Rush code path that has this bug. useWorkspaces is technically still "experimental" but it is widely used and now very stable. It will be on by default in the next major Rush release. But even if you do this, it's still recommended to run rush update --full regularly.

I wonder if we should document this better.

octogonz avatar Mar 10 '21 07:03 octogonz

Thanks for the fasten response, I try either the rush update --full and the useWorkspaces=true, and both fixed the problem. You can close the issue if you want.

m4ss1m0g avatar Mar 10 '21 15:03 m4ss1m0g

I think we should at the very least improve the docs. If we can't fix the bug easily, we could change the error message to give more useful advice than You have encountered a software defect.

octogonz avatar Mar 10 '21 19:03 octogonz

I think we should at the very least improve the docs. If we can't fix the bug easily, we could change the error message to give more useful advice than You have encountered a software defect.

Or maybe a message with more certain information targeting this issue? Software defect really doesn't give any information for next step.

m1heng avatar Mar 20 '21 14:03 m1heng

@iclanton we are hearing about this issue a lot lately. I think we should bump the priority for investigating it. If there isn't an easy fix, maybe we could at least improve the error message to direct people to the known workarounds.

👉 Note that this same error message is reported (for completely different reasons) when using PNPM 6. Issue https://github.com/microsoft/rushstack/issues/2601 is tracking the PNPM 6 incompatibility.

octogonz avatar Apr 14 '21 17:04 octogonz

I upgraded pnpm to v7 and encountered this error. rush update --full didn't fix the problem for me. To repro check out this branch then run rush update --full

https://github.com/jeremymeng/azure-sdk-for-js/tree/engsys/bump-rush-pnpm-version

jeremymeng avatar May 20 '22 21:05 jeremymeng

Just noticed that this issue is for PNPM 5. Should I log a new issue for PNPM 7 @octogonz?

jeremymeng avatar Jun 03 '22 17:06 jeremymeng

@jeremymeng are you using useWorkspaces=true?

octogonz avatar Jun 04 '22 06:06 octogonz

@jeremymeng are you using useWorkspaces=true?

@octogonz No, we did attempt to to use useWorkspaces=true in our repo before but ran into issues that we couldn't resolve easily.

jeremymeng avatar Jun 06 '22 20:06 jeremymeng

I'm seeing this too with latest rush and pnpm, 5.74.0 and 7.30 respectively

fringd avatar Jun 23 '22 15:06 fringd

Team mate had the same issue. useWorspaces fixed it.

mikaelmattsson avatar Jul 01 '22 07:07 mikaelmattsson