rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] ERROR: Internal Error: Cannot find installed dependency "@jest/globals"

Open nipunn1313 opened this issue 3 years ago • 12 comments

Summary

pnpm 7.1.9 + rush 5.71.0 First ran into the issue when updating from pnpm 6.32.20 -> 7.1.9

When running npx rush update, I consistently get

ERROR: Internal Error: Cannot find installed dependency "@jest/globals" in "/Users/nipunn/src/convex/npm-packages/common/temp/node_modules/.pnpm/local++Users+nipunn+src+convex+npm-packages+common+temp+projects+common.tgz_gadim7yol4qtpdtcwtlb7rbkka/node_modules" You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

I tried npx rush purge ; npx rush update - but I still run into the issue.

Repro steps

It's hard to know exactly what reproes this since rush is so stateful, but I currently have a repro with pnpm 7.1.9 and rush 5.71.0. When running npx rush update

Details

In case this is useful, I grepped for @jest/globals - which is the claimed missing dependency

➜  ✗ rg "@jest/globals"
common/config/rush/pnpm-lock.yaml
15:  '@jest/globals': ~28.1.0
151:  '@jest/globals': 28.1.0
3744:  /@jest/globals/27.5.1:
3753:  /@jest/globals/28.1.0:
10132:      '@jest/globals': 27.5.1
15187:      '@jest/globals': 28.1.0
15250:      '@jest/globals': 28.1.0
15499:      '@jest/globals': 28.1.0

@convex-dev/common/package.json
40:    "@jest/globals": "~28.1.0"

@jest/globals are in devDependencies section of package.json

Standard questions

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

Question Answer
@microsoft/rush globally installed version? 5.71.0
rushVersion from rush.json? 5.71.0
useWorkspaces from rush.json? unset
Operating system? mac
Would you consider contributing a PR? this seems out of my wheelhouse
Node.js version (node -v)? v16.15.1

nipunn1313 avatar Jun 06 '22 18:06 nipunn1313

I'm having a similar problem, only with different dependencies.

rodrigoscna avatar Jun 09 '22 20:06 rodrigoscna

Can you try enabling the useWorkspaces option? This sounds like it's something to do with your specific dependency topology.

iclanton avatar Jun 13 '22 18:06 iclanton

I did the following

  1. Update pnpmVersion from 6.32.20 to 7.2.1 and ran npx rush update. Ran into
ERROR: Internal Error: Cannot find installed dependency "@jest/globals" in
"/Users/nipunn/src/convex/npm-packages/common/temp/node_modules/.pnpm/local++Users+nipunn+src+convex+npm-packages+common+temp+projects+common.tgz_gadim7yol4qtpdtcwtlb7rbkka/node_modules"
You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
  1. Enabled useWorkspaces and ran npx rush update. Ran into
The shrinkwrap file has not been updated to support workspaces. Run "rush update --full" to update the shrinkwrap file.
  1. Ran npx rush update --full. Things worked

This made me suspicious, so I reset everything and tried in a different order

  1. Update pnpmVersion from 6.32.20 to 7.2.1 and ran npx rush update --full. This still ran into
ERROR: Internal Error: Cannot find installed dependency "@jest/globals" in
"/Users/nipunn/src/convex/npm-packages/common/temp/node_modules/.pnpm/local++Users+nipunn+src+convex+npm-packages+common+temp+projects+common.tgz_tyanovuupthlsfq47bxwasr2c4/node_modules"
You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
  1. Enabled useWorkspaces and ran npx rush update --full. Things worked.

It sounds like the default useWorkspaces: false doesn't seem to work with pnpm 7 and rush - possibly having something to do with our specific dependency topology.

nipunn1313 avatar Jun 13 '22 18:06 nipunn1313

Same problem, when i specify my own local project package as dependency in package.json of my another rush project package. Error highlights the first dep in package.json of secified package.

pnpm 7.5.2 rush 5.75.0

maxpavlov9991 avatar Jul 22 '22 00:07 maxpavlov9991

Exact same problem as described here. Only useWorkspaces true worked with pnpm 7. Downgroding pnpm to 6.33.0 worked as well. But as described pnpm 7 and rush 5 only work with the useWorkspaces flag on true.

mlippens avatar Aug 02 '22 14:08 mlippens

@iclanton @D4N14L @elliot-nelson My company's monorepo is still on PNPM 6, and so is the Rush Stack open source repo.

Are any of you using PNPM 7 yet? Have you encountered this issue?

octogonz avatar Aug 02 '22 20:08 octogonz

@nipunn1313 @mlippens Does rush --debug update print a meaningful callstack?

octogonz avatar Aug 02 '22 20:08 octogonz

"/Users/nipunn/src/convex/npm-packages/common/temp/node_modules/.pnpm/local++Users+nipunn+src+convex+npm-packages+common+temp+projects+common.tgz_02706d83d6761871224e5f01d7ca35f7/node_modules"
You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

Error: Internal Error: Cannot find installed dependency "@jest/globals" in "/Users/nipunn/src/convex/npm-packages/common/temp/node_modules/.pnpm/local++Users+nipunn+src+convex+npm-packages+common+temp+projects+common.tgz_02706d83d6761871224e5f01d7ca35f7/node_modules"

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
    at PnpmLinkManager._createLocalPackageForDependency (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/logic/pnpm/PnpmLinkManager.js:237:19)
    at PnpmLinkManager._linkProject (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/logic/pnpm/PnpmLinkManager.js:170:42)
    at PnpmLinkManager._linkProjects (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/logic/pnpm/PnpmLinkManager.js:73:28)
    at PnpmLinkManager.createSymlinksForProjects (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/logic/base/BaseLinkManager.js:192:20)
    at PnpmLinkManager.createSymlinksForProjects (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/logic/pnpm/PnpmLinkManager.js:62:21)
    at RushInstallManager.postInstallAsync (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/logic/installManager/RushInstallManager.js:469:31)
    at RushInstallManager.doInstallAsync (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/logic/base/BaseInstallManager.js:154:20)
    at async UpdateAction.runAsync (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/cli/actions/BaseInstallAction.js:125:13)
    at async RushCommandLineParser.onExecute (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js:202:13)
    at async RushCommandLineParser._wrapOnExecuteAsync (/Users/nipunn/.rush/node-v16.15.0/rush-5.71.0/node_modules/@microsoft/rush-lib/lib/cli/RushCommandLineParser.js:198:9)
error: Recipe `rush` failed on line 71 with exit code 1

Not sure if it's meaningful, but here's what it is.

pnpmVersion = 7.8.0 rushVersion = 5.71.0 (in rush.json) rush version = 5.71.0

nipunn1313 avatar Aug 02 '22 20:08 nipunn1313

Okay, yes that is helpful. I wasn't reading carefully that you have useWorkspaces=false in rush.json. This mode is obsolete and will be removed eventually.

For some background, Rush's useWorkspaces=false mode predates PNPM's support for monorepo workspaces. In the old days, PNPM could only install one project at a time, so Rush's strategy was to generate a fake project common/temp/package.json that depended on all the projects in your monorepo, and run pnpm install on that "one project". Then Rush's PnpmLinkManager would create a node_modules folder for each project, populating it with symlinks that point into the appropriate places under common/temp/node_modules. This algorithm is complicated, because it crawls the individual dependency folders (to reverse the phantom dependencies that arise in a single-project install). Thus Rush needs to accommodate all the nuances of how PNPM lays out the node_modules folder, which today is very sophisticated. One those assumptions is probably broken in newer PNPM releases.

With useWorkspaces=true, it's no longer necessary for Rush to do any of this. PNPM itself can now generate proper node_modules folders for every project. PNPM specializes in this problem and obviously has much more context and information, so it does a better job than Rush could ever do. There really isn't any upside to useWorkspaces=false today. That is why we're phasing it out.

octogonz avatar Aug 03 '22 07:08 octogonz

@octogonz, ok thanks for the reply. Maybe this should be clearly documented in the documentation? Or in this case even a meaningful warning could also be printed when pnpm >= 8 has been detected, as it just doesn't work any longer.

Thanks for the clarification

mlippens avatar Aug 03 '22 07:08 mlippens

I've marked this as help wanted. If someone wants to debug it, what you would do is run your rush install in the VS Code debugger and then look at the @jest/globals path from the log above. If you run require.resolve('@jest/globals') from the ...common.tgz_02706d83d6761871224e5f01d7ca35f7/ folder, where did @jest/globals actually get installed? Why isn't it in the expected folder? That would suggest some mitigation. It's possible that simply printing a warning and ignoring the missing folder would still produce a usable installation.

If someone wants to contribute a PR, we'll be happy to accept it. But as explained above, the maintainers are unlikely to prioritize working on this ourselves.

octogonz avatar Aug 03 '22 07:08 octogonz

Maybe this should be clearly documented in the documentation?

Yes

Or in this case even a meaningful warning could also be printed when pnpm >= 8 has been detected, as it just doesn't work any longer.

If that's true, then I agree.👍 Printing a warning is a pretty easy PR. It would be very appreciated if someone could do that. 😉

octogonz avatar Aug 03 '22 07:08 octogonz