-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New library template gitignores Cargo.lock
#11510
Comments
This is by design, you can check out https://doc.rust-lang.org/stable/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries. |
I'm aware of this argument and mentioned it in the notes. It is true that However, it will help to build the library itself (and associated items like tests and examples) in a known configuration. This is useful for the purpose of developing the library itself. Suppose I made a library and published it on GitHub. You check it out and try to build it and run tests. It works on my machine and doesn't work on yours, because your It could be argued that this shouldn't happen in a correct library. A correct library is supposed to work for all combinations of dependency versions compatible with the constraints specified in |
I will go ahead closing this. If anyone feels it's wrong, feel free to commment. We can then consider re-open. |
Problem
The
.gitignore
file in the new library template lists theCargo.lock
file. This can make it more difficult to reproduce builds and perform bisections using thegit bisect
command.Steps
cargo new --bin my_app
to create a new binary crate.cargo new --lib my_lib
to create a new library crate.The
.gitignore
file inmy_app
does not listCargo.lock
, but the.gitignore
file inmy_lib
does.Possible Solution(s)
The new library crate template shouldn't add
Cargo.lock
to.gitignore
, same as the new binary crate template.Notes
Including the
Cargo.lock
file in the repository can improve the developer experience by making it more likely that the library will compile when runninggit clone
andcargo check
.It is also a question orthogonal to that of including
Cargo.lock
in the packaged crate. Even ifCargo.lock
is not used during dependency resolution, it can still be useful to have in the repository for the purposes of reproducibility and hermeticity when developing the library itself.Version
The text was updated successfully, but these errors were encountered: