fix(install): use packaged lockfile by default - #17388
Conversation
|
Thanks for the pull request, and welcome! The Rust Project has assigned @weihanglo (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
| .with_status(101) | ||
| .run(); | ||
| p.cargo("install --path . --locked").run(); | ||
| p.cargo("install --path .").run(); |
There was a problem hiding this comment.
This drops the snapshot asserting [..]not rust[..]. Was it intentional? Otherwise we might want to keep it.
| .run(); | ||
| p.cargo("install --path . --locked").run(); | ||
| p.cargo("install --path .").run(); | ||
| p.cargo("install --path . --locked --force").run(); |
There was a problem hiding this comment.
This --locked --force change is better to be in its own test commit, prior to the fix commit, and we might want to have the same assertion verifying it actually respects the lockfile.
There was a problem hiding this comment.
Okay, that's fine. I'll have it ready.
|
Thanks for the contribution. Would you mind cleaning up the template strings in the PR description? |
|
btw thank you for moving this forward! The recent arrayref situation shows how important this change is! |
|
🙏 Happy to help. I'd love to get more involved with cargo even after this. |
5ad02ea to
07a27bc
Compare
|
@gmemuriuki You probably want to rebase onto master branch to fix the failed job: https://github.com/rust-lang/cargo/actions/runs/33005586808/job/98298352305?pr=17388 |
|
Sure, I'm on it. |
Keep explicit --locked coverage independent from tests for cargo install's default lockfile behavior.
07a27bc to
61aec32
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Make registry and path installs honor Cargo.lock without requiring --locked. Keep fallback behavior when no lockfile is available, including the compatibility warning for explicit --locked.
Cargo install now honors an an available lockfile, so no caller needs Workspace::ignore_lock. Remove the unused state and unreachable resolver and MSRV-help branches while retaining the no-lockfile yanked-check guard.
61aec32 to
b7c0e0f
Compare
|
@rfcbot fcp merge This PR implements the policy we decided on in the 2026-04-28 meeting as described at #7169 (comment) |
|
@epage has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
@rfcbot reviewed |
|
@rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
View all comments
What does this PR try to resolve?
This PR closes #7169
cargo builduses an existingCargo.lock, whilecargo installpreviously ignored a package'sCargo.lockfile unless--lockedwas passed. As a result, building and testing a binary could use one set of dependency version while installing the same binary selected another.This can cause installation to fail even though the package built and tested successfully. This also leaves maintainers supporting dependency versions they didn't test or sign-up for.
Following Cargo Team Decision,
this PR makes
cargo installuse the available lockfile by default. This givescargo installthe existing behavior ofcargo install --locked.--lockedremains accepted but it is a no-op. When a package does not contain a lockfile, Cargo fallback to resolving its deps normally. Explicitly passing--lockedstill emits the existing missing-lockfile warning.The warning for yanked deps is preserved, but it's suggestion to retry without
--lockedis removed because doing so no longer changes dep resolution.Deprecating
--lockedand adding an option to ignore the packaged lockfile remains a separate effort to be considered as discussed in the decision.How to test and review this PR?
There are four commits structured in this manner:
cargo install --lockedhonors packaged lockfile.ignore_lockworkspace state and resolver path.Test covers
--lockedremaining accepted and producing the same resolution.--locked.cargo-packageyanked-dependency help remaining unchanged.The following tests were run: