Skip to content

Install cargo tools with locked dependencies - #17377

Merged
weihanglo merged 1 commit into
rust-lang:masterfrom
konstin:konsti/cargo-install-locked
Aug 21, 2026
Merged

Install cargo tools with locked dependencies#17377
weihanglo merged 1 commit into
rust-lang:masterfrom
konstin:konsti/cargo-install-locked

Conversation

@konstin

@konstin konstin commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Installing cargo tools (cargo install) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using cargo install --locked reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all rg "cargo install" hits in the rust-lang/rust and added --locked to all but explanatory examples (such as cargo's docs on cargo install itself). I validated that those tools publish functioning Cargo.locks with https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0. These are the broken out changes for cargo.

rust-lang/rust#161428

@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 20, 2026
@rustbot

rustbot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @epage, @weihanglo
  • @epage, @weihanglo expanded to epage, weihanglo
  • Random selection from epage, weihanglo

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the change to cargo install --locked being the default has been accepted: #7169 (comment).

View changes since this review

[`cargo-local-registry`][cargo-local-registry] subcommand,
[available on crates.io][cargo-local-registry] and can be installed with
`cargo install cargo-local-registry`.
`cargo install --locked cargo-local-registry`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always have ? about this tool and local registries. They are like second-class citizens, but anyway.

Installing cargo tools (`cargo install`) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using `cargo install --locked` reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all `rg "cargo install"` hits in the rust-lang/rust and added `--locked` to all but explanatory examples (such as cargo's docs on `cargo install` itself). I validated that those tools publish functioning `Cargo.lock`s with https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0. These are the broken out changes for cargo.

rust-lang/rust#161428
@konstin
konstin force-pushed the konsti/cargo-install-locked branch from 8a7c146 to 33e72b9 Compare August 21, 2026 09:25
@rustbot

rustbot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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.

@konstin

konstin commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

I had to rebase for clippy (#17378).

@weihanglo
weihanglo added this pull request to the merge queue Aug 21, 2026
Merged via the queue into rust-lang:master with commit 09ddce4 Aug 21, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Aug 22, 2026
Update cargo submodule

5 commits in 514c56dd7321eecbfdcf9b6479519cf4edfab906..e8cb624d5701824f46a2ec5873cfd59ee3d2f66c
2026-08-19 00:31:04 +0000 to 2026-08-22 00:23:45 +0000
- feat(config): Add build.fingerprint (rust-lang/cargo#17382)
- chore: bump to 0.101.0; update changelog (rust-lang/cargo#17379)
- Install cargo tools with locked dependencies (rust-lang/cargo#17377)
- test(compile): Clean up freshness tests (rust-lang/cargo#17376)
- Fix clippy warning (rust-lang/cargo#17378)

r? ghost
@rustbot rustbot added this to the 1.100.0 milestone Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-documenting-cargo-itself Area: Cargo's documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants