Skip to content
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

Should Cargo.lock be committed, or added to .gitignore? #315

Closed
zr40 opened this issue Aug 4, 2014 · 12 comments
Closed

Should Cargo.lock be committed, or added to .gitignore? #315

zr40 opened this issue Aug 4, 2014 · 12 comments

Comments

@zr40
Copy link

zr40 commented Aug 4, 2014

There doesn't appear to be any documentation about the purpose of Cargo.lock and guidelines for handling it.

Should Cargo.lock be committed to a project's repository, or should it be added to .gitignore?

/cc nickel-org/nickel.rs#50

@alexchandel
Copy link

I heard on IRC it should be ignored for libraries, tracked for binaries.

@alexcrichton
Copy link
Member

Yes, libraries should ignore Cargo.lock but binaries/applications should check-in Cargo.lock.

I believe @wycats is going to work on some documentation for this in the coming days.

@SimonSapin
Copy link
Contributor

If Cargo.lock has meaningful content (as opposed to being a way to multiple instances of Cargo to run simultaneously), shouldn’t it be named something else?

@alexcrichton
Copy link
Member

This is now documented, so I'm going to close this.

jsanders added a commit to jsanders/rust-gmp that referenced this issue Oct 25, 2014
@heyman
Copy link

heyman commented Dec 25, 2014

The documentation seems to reside on a new subdomain. The information regarding Cargo can now be found at: http://doc.crates.io/guide.html#cargo.toml-vs-cargo.lock

@AndreasHassing
Copy link

AndreasHassing commented Apr 30, 2017

The answer in this FAQ describes the reasoning really well: http://doc.crates.io/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries

Just leaving this here, as Google'ing for "Crate.lock gitignore" leads to this issue, and @alexcrichton's link is dead.

lo48576 pushed a commit to lo48576/lazy-init that referenced this issue Nov 9, 2017
Libraries should ignore `Cargo.lock`.
See <rust-lang/cargo#315> and
<http://doc.crates.io/guide.html>.
khuey pushed a commit to khuey/lazy-init that referenced this issue Nov 9, 2017
Libraries should ignore `Cargo.lock`.
See <rust-lang/cargo#315> and
<http://doc.crates.io/guide.html>.
fpoli added a commit to fpoli/rucaja that referenced this issue Nov 10, 2017
According to [1], [2] Cargo.lock should be added to gitignore for libraries.

[1](http://doc.crates.io/guide.html#cargo.toml-vs-cargo.lock)
[2](rust-lang/cargo#315)
fpoli added a commit to fpoli/rucaja that referenced this issue Nov 10, 2017
According to [1], [2] Cargo.lock should be added to gitignore for libraries.

[1](http://doc.crates.io/guide.html#cargo.toml-vs-cargo.lock)
[2](rust-lang/cargo#315)
fpoli added a commit to fpoli/rucaja that referenced this issue Nov 10, 2017
According to [1], [2] Cargo.lock should be added to gitignore for libraries.

[1](http://doc.crates.io/guide.html#cargo.toml-vs-cargo.lock)
[2](rust-lang/cargo#315)
fpoli added a commit to fpoli/rucaja that referenced this issue Nov 10, 2017
According to [1], [2] Cargo.lock should be added to gitignore for libraries.

[1](http://doc.crates.io/guide.html#cargo.toml-vs-cargo.lock)
[2](rust-lang/cargo#315)
fpoli added a commit to fpoli/rucaja that referenced this issue Nov 10, 2017
According to [1], [2] Cargo.lock should be added to gitignore for libraries.

[1](http://doc.crates.io/guide.html#cargo.toml-vs-cargo.lock)
[2](rust-lang/cargo#315)
fpoli added a commit to fpoli/rucaja that referenced this issue Nov 10, 2017
According to [1], [2] Cargo.lock should be added to gitignore for libraries.

[1](http://doc.crates.io/guide.html#cargo.toml-vs-cargo.lock)
[2](rust-lang/cargo#315)
dsprenkels pushed a commit to dsprenkels/sss-cli that referenced this issue Dec 31, 2017
Cargo.lock should be committed for binaries, see also
rust-lang/cargo#315.
dvberkel added a commit to fifth-postulate/packing-puzzle that referenced this issue Feb 5, 2018
jgraef pushed a commit to nimiq/core-rs that referenced this issue Feb 4, 2019
@montao
Copy link

montao commented Feb 13, 2019

This is now documented, so I'm going to close this.

Link does not work. Maybe it is this now https://doc.rust-lang.org/cargo/guide/

jontze added a commit to jontze/mdbook-katex that referenced this issue Dec 11, 2022
To ensure reproducible builds for the compiled binaries it's recommended
to add the `Cargo.lock` file to version control.

Refs.:
- Cargo Book FAQs: https://doc.rust-lang.org/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries
- Discussion in a github issue: rust-lang/cargo#315
jontze added a commit to jontze/mdbook-katex that referenced this issue Dec 12, 2022
To ensure reproducible builds for the compiled binaries it's recommended
to add the `Cargo.lock` file to version control.

Refs.:
- Cargo Book FAQs: https://doc.rust-lang.org/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries
- Discussion in a github issue: rust-lang/cargo#315
thomastaylor312 pushed a commit to krustlet/oci-distribution that referenced this issue Mar 2, 2023
As per rust-lang/cargo#315

Signed-off-by: Matthew Fisher <matt.fisher@fermyon.com>
@choleraehyq
Copy link

Cargo.lock not only specifies the specific versions of dependencies, but also provides the checksums of its dependencies for build system to verify. From this security aspect, maybe we need to commit Cargo.lock along with Cargo.toml?

Go team clearly point out this reason in doc https://go.dev/wiki/Modules#should-i-commit-my-gosum-file-as-well-as-my-gomod-file.

@weihanglo
Copy link
Member

Please read the recent blog post "Change in Guidance on Committing Lockfiles", and the up-to-date guidance.
See also #8728.

@binkley
Copy link

binkley commented Jan 1, 2024

I read through the links provided in the comments, and @weihanglo 's posting was the only one to provide a currently active doc link: https://doc.rust-lang.org/cargo/faq.html#why-have-cargolock-in-version-control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests