Forrest logo
back to the cargo tool

cargo-build:tldr:15d47

cargo-build: Require that `Cargo.lock` is up to date.
$ cargo build --locked
try on your machine

The command "cargo build --locked" is used in the Rust programming language and the Cargo package manager. Let's break it down:

  • "cargo" refers to the command-line tool for managing Rust projects and dependencies.
  • "build" is a Cargo subcommand that compiles the Rust code in the current project directory and its dependencies into an executable or library.
  • "--locked" is an optional flag that instructs Cargo to use the exact versions of dependencies specified in the Cargo.lock file. The Cargo.lock file records the exact versions of dependencies that were previously resolved and used successfully. By using "--locked", Cargo avoids updating the dependencies to newer versions that might have been released since the last build.

In summary, "cargo build --locked" compiles your Rust project using the specific versions of dependencies specified in the Cargo.lock file, ensuring consistency across builds and helping to avoid unintentional breaking changes introduced by updated dependencies.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the cargo tool