rushstack
rushstack copied to clipboard
[rush] Internal Error "Cannot find installed dependency" with PNPM 5
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
- Download the attached solution rush-nest.zip
- run
rush install - 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 |
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.
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.
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.
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.
@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.
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
Just noticed that this issue is for PNPM 5. Should I log a new issue for PNPM 7 @octogonz?
@jeremymeng are you using useWorkspaces=true?
@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.
I'm seeing this too with latest rush and pnpm, 5.74.0 and 7.30 respectively
Team mate had the same issue. useWorspaces fixed it.