microsoft/rushstack

[rush] `rush install --only .` installs all dependencies in the monorepo instead of only the dependencies in current folder/project

elenasch opened this issue · 10 comments

Summary

The RushJS documentation for rush install states that I can run with --only flag which will select only the one specified project and install only the dependencies for that project. However that doesn't seem the case and all monorepo's projects' dependencies are still getting installed.

Repro steps

To reproduce, run rush purge first, then rush install --only . in any folder, and see what gets installed. You will see that rush installs all monorepo dependencies, and not only the specified project.

It takes a significant amount of time to install and I can see a line line this in logs Scope: 8 of 219 workspace projects and Progress: resolved 3620, reused 3550, downloaded 0, added 3076 in logs.

I tested with rush install --to . as well, and I see this log line Scope: 8 of 219 workspace projects. 8 is the correct number of selected projects as oppose to Scope: all 219 workspace projects generated for rush install

However, watching the installation progress, it always results in Progress: resolved 3620, reused 0, downloaded 3550, added 3076 done --> same amount of packages downloaded and added for any of the flags (or no flags) specified

Standard questions

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

Question Answer
@microsoft/rush globally installed version? 5.112.2
rushVersion from rush.json? 5.112.2
useWorkspaces from rush.json? true
Operating system? MacOS
Would you consider contributing a PR? No
Node.js version (node -v)? v20.10.0

This seems like a recent regression. @dmichon-msft - can you take a look at this, since you refactored the project selection logic? This may have been broken by recent changes to the installation algorithm. @g-chao, @william2958 - Would you two mind taking a look at this as well, as you guys changed this logic most recently?

Do we know which Rush version introduced this regression?

Notice that @elenasch cited Rush 5.112.2 which is from December. Is this really a regression? Maybe it is just an edge case.

I'm actually unclear what rush install --only . is meant to do by design. Is it even valid? 🤔

It might make sense to forbid the unsafe selectors (--only, --impacted-by, --impacted-by-except) for rush install and rush update.

@dmichon-msft what do you think?

Similar issue happens with --to. I can see how --only is not always safe, but -to should be, and installing only a subset of deps would really help reduce the time installing (specifically in CI where you don't have previously installed deps like on local )

If you run with --debug it should log the command being forwarded to pnpm. Are the --filter arguments not showing up in that command?

It looks like it is there. Are there any other settings that look out of place ?

Invoking package manager: <my path>/.rush/node-v20.10.0/pnpm-8.13.1/node_modules/pnpm/bin/pnpm.cjs install --store <my path>/common/temp/pnpm-store --config.cacheDir= <my path>/common/temp/pnpm-store --config.stateDir= <my path>/common/temp/pnpm-store --no-prefer-frozen-lockfile --reporter ndjson --no-strict-peer-dependencies --config.auto-install-peers=false --config.resolutionMode=highest --config.ignoreCompatibilityDb --recursive --link-workspace-packages false --filter my-npm-package...

@dmichon-msft I ran just the raw pnpm command I posted above, and it did the right thing with only installing the one project in filter (took about 5.5s) , then ran the rush install --only . and it took ~54s.

hx-dl commented

Similar issue happens with --to. I can see how --only is not always safe, but -to should be, and installing only a subset of deps would really help reduce the time installing (specifically in CI where you don't have previously installed deps like on local )

I encountered a similar problem. After we upgraded pnpm7 to pnpm8, rush install --to projectName no longer installs the dependencies of the project specified by --to. After execution, all dependencies of the entire monorepo are installed. I would like to ask if anyone has the same problem.

rush version: 5.115.0
pnpm version: 8.15.6

If I revert back to pnpm7, everything will be normal.

@hx-dl I encountered the same problem and created an issue last year already which links to the related issue on pnpm side: #4218