LinuxCommandLibrary

cargo-generate-lockfile

Create or regenerate Cargo.lock for a Rust project

TLDR

Generate lock file

$ cargo generate-lockfile
copy
Regenerate with latest versions
$ cargo generate-lockfile
copy
Generate with specific manifest
$ cargo generate-lockfile --manifest-path [path/to/Cargo.toml]
copy
Generate with custom lockfile path
$ cargo generate-lockfile --lockfile-path [/tmp/Cargo.lock]
copy

SYNOPSIS

cargo generate-lockfile [options]

DESCRIPTION

cargo generate-lockfile creates or rebuilds Cargo.lock for the current package or workspace. If lockfile exists, rebuilds with latest available versions of all packages.

PARAMETERS

--manifest-path path

Path to Cargo.toml
--lockfile-path path
Custom lockfile path (must end with Cargo.lock)
--locked
Assert exact same dependencies as original lockfile
--offline
Don't access network
--frozen
Equivalent to --locked and --offline
-v, --verbose
Verbose output (use twice for very verbose)
-q, --quiet
Suppress log messages

BEHAVIOR

Creates new Cargo.lock if none exists. Rebuilds existing lockfile with newest compatible versions. Use cargo update for more control over version updates.

CAVEATS

Ensures reproducible builds by locking dependency versions. Useful in CI pipelines for deterministic builds. Consider committing Cargo.lock for applications, not libraries.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community