[rush] Provide an option to make the committed shrinkwrap capture the exact installation plan #1300
Labels
effort: medium
Needs a somewhat experienced developer
enhancement
The issue is asking for a new feature or design change
help wanted
If you're looking to contribute, this issue is a good place to start!
Although
rush install
always produces a /deterministic/ outcome for a given input, the installation plan may not exactly correspond to the shrinkwrap file (aka "lockfile"). In other words,rush install
is a deterministic function of common/config/rush/pnpm-lock.yaml file plus the package.json files for all the projects, not the shrinkwrap file alone.Benefits: This feature was introduced to minimize spurious churn in the shrinkwrap file, which frequently causes annoying merge conflicts in a busy monorepo.
Drawbacks: People have found this feature counterintuitive, because it changes the meaning of the shrinkwrap file. Also in some situations it's important for the exact installation plan to be tracked by Git (e.g. when applying a hotfix to an old release branch, where you want to avoid disturbing any other package versions).
Algorithm details
Here's a summary of the algorithm when using PNPM:
There are 3 files:
A. common/config/rush/pnpm-lock.yaml - the "committed" version that is tracked by Git
B. common/temp/pnpm-lock.yaml - the version that PNPM sees when invoked in common/temp
C. common/temp/pnpm-lock-preinstall.yaml - a backup copy of pnpm-lock.yaml, for diagnostic purposes to compare with B
rush install
reads A, makes some fixes to it, and writes out B and C before invokingpnpm install
pnpm install
reads B and might rewrite it with some changes, making it different from C. (But by design,rush install
does not copy these changes back to A; the deviations are allowable because they are supposed to be fully deterministic. The reason is to minimize churn that causes Git merge conflicts.)rush update
is likerush install
but it does copy B -> A, but only when Rush determines that the changes are interesting.rush update --full
deletes B, then runspnpm install
to create B, then copies B -> AProposed changes
Add a rush.json setting for disabling this optimization. Maybe we could call it
minimizeShrinkwrapChurn
, which would betrue
when the optimization is enabled.We could also add a command-line parameter such as
rush update --resync-shrinkwrap
to force copying common/temp/pnpm-lock.yaml --> common/config/rush/pnpm-lock.yaml if there are any differences.When the files are different, Rush install could print an informational message to the log indicating this situation. Something like: "The installation has differences from the shrinkwrap file because minimizeShrinkwrapChurn was enabled."
@iclanton
The text was updated successfully, but these errors were encountered: