microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.9k stars 595 forks source link

[rush] Shouldn't version bumping update `pnpm-lock.yaml` too? #4977

Open ingun37 opened 3 days ago

ingun37 commented 3 days ago

Summary

Version bumping does not automatically update pnpm-lock.yaml. Therefore it needs to be updated manually. Otherwise, subsequent PRs fail at rush install or suffers from pnpm-lock.yaml conflict.

Details

When I do rush publish --publish --apply ..., the following version bump commit updates all the versions in the package.json files of the target branch. But since it doesn't update pnpm-lock.yaml, any subsequent PRs that is stemming from the target branch will suffer from the inconsistency between package.json and pnpm-lock.yaml. For example rush install won't work so they will have to run rush update by themselves. Shouldn't version bumping update pnpm-lock.yaml too?

Standard questions

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

Question Answer
@microsoft/rush globally installed version? 5.129.6
rushVersion from rush.json? 5.129.6
useWorkspaces from rush.json? undefined
Operating system? Linux
Would you consider contributing a PR? Yes
Node.js version (node -v)? 20.15.1
iclanton commented 2 days ago

Local versions aren't supposed to be in the pnpm-lock file. Can you share a repro repo?

ingun37 commented 2 days ago

@iclanton In this repro repo

  1. I merged ingun37/rush-bug-repro#1
  2. I ran rush publish ...
  3. It produced version bump commit ingun37/rush-bug-repro@9083699370a88412feb640cdcf42ca53a9824de4 (the current head) which has updated package.jsons.
  4. Now rush install fails from main because the pnpm-lock.yaml's not updated. It would only succeed after rush update and pnpm-lock.yaml is updated.
dmichon-msft commented 15 hours ago

Enabling useWorkspaces should resolve this issue. Non-workspace mode is deprecated, and in workspace mode your package.json files should just contain workspace:* as the version specifier for packages within the repository, which means they won't change in a way that impacts pnpm-lock.yaml on version bump.

ingun37 commented 10 hours ago

@dmichon-msft Thanks that fiix it but there's a preceding problem. I didn't change the workspace version but Rush did. I also reproduced in the same repository and this is the step.

  1. Make a branch (ingun37/rush-bug-repro#6)
  2. Update code & do rush change
  3. Publish prerelease targeting the same branch with rush publish ... --prerelease-name prerelease --target-branch some-pr-6.
  4. In the version bump commit (ingun37/rush-bug-repro@38fda9c) the *workspace version is changed from `workspace:toworkspace:1.0.8-prerelease`**
  5. Squash Merge to main
  6. Do the rush publish
  7. In the version bump commit (the current head, ingun37/rush-bug-repro@3db76b9) the workspace version is change from workspace:1.0.8-prerelease to workspace:1.0.8

I wanted to publish prerelease from PR for some integration test with other external projects. But by doing so the workspace version changes. Should I do the prerelease publish process differently?