rustrust-cargorust-crates

Should Cargo.lock be committed when the crate is both a rust library and an executable?


I 've read https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

If I understand correctly, when I commit Cargo.lock into my crate (which is both a library and an executable)'s repository, and also, publish it to crates.io, downstream crates will ignore it and build it's own snap, right?


Solution

  • I found the best practice from the excellent project ripgrep, which splits itself into several crates. For the binary crate in the root, they track Cargo.lock, but for library crates that provide functionality for the application (for example, pcre2), they don't.