Cargo.lock records the resolved versions of direct and indirect package dependencies, along with checksums for integrity verification. Cargo.toml specifies dependency requirements; the lock file records the resolved dependency tree. section 2.2.1 section 2.2
Run `cargo update` to update Cargo.lock to the newest available crates permitted by the dependency specifications. A requirement that allows compatible upgrades gives Cargo more flexibility than an exact version requirement. section 2.2
Handle the lock file according to the project’s role:
- For applications, commit Cargo.lock alongside Cargo.toml to help keep published releases consistent when third-party libraries change. section 2.2.1
- For libraries, omit Cargo.lock from version control; with Git, add it to .gitignore. This leaves downstream packages free to update indirect dependencies as needed. section 2.2.1
A Cargo workspace shares one top-level Cargo.lock and resolved dependency tree across its members. Workspace membership does not itself declare dependencies: define a dependency between members when one uses another. section 2.10
Workspace dependency
In a workspace containing `subproject`, declare `subproject = { path = "./subproject" }` under `[dependencies]` and list `subproject` in `[workspace].members`. The projects then share the workspace’s top-level lock file. section 2.10
