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

Commit Cargo.lock by default #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

epilys
Copy link
Member

@epilys epilys commented Oct 20, 2023

Summary of the PR

We audit crates for vulnerabilities on CI already. Lacking a lockfile means the audit is meaningless if the dependency versions can change between subsequent runs because of a e.g. minor or patch semver fix of a security vulnerability.

There are advantages and disadvantages to having deterministic dependencies:

Advantages:

  • Aforementioned auditing
  • Bisectability
  • More predictable behavior when binaries are installed with cargo install --locked ....

Disadvantages:

  • Cargo's dependency resolution can end up duplicating transitive dependencies in downstream crates which use a rust-vmm dependency that shares dependencies with more than one of the others. This can be inspected with cargo-tree.
  • Requires extra maintainer attention and effort to keep the lockfile up-to-date.

The Rust Cargo team currently recommends against committing the lockfile for library crates in version control, but plans to reverse this
recommendation in the future. You can read the new Cargo
recommendations in the Nightly version docs:

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR are signed (with git commit -s), and the commit
    message has max 60 characters for the summary and max 75 characters for each
    description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

We audit crates for vulnerabilities on CI already. Lacking a lockfile
means the audit is meaningless if the dependency versions can change
between subsequent runs because of a e.g. minor or patch semver fix of a
security vulnerability.

There are advantages and disadvantages to having deterministic
dependencies:

Advantages:

- Aforementioned auditing
- Bisectability
- More predictable behavior when binaries are installed with `cargo
  install --locked ...`.

Disadvantages:

- Cargo's dependency resolution can end up duplicating transitive
  dependencies in downstream crates which use a `rust-vmm` dependency
  that shares dependencies with more than one of the others. This can be
  inspected with `cargo-tree`.
- Requires extra maintainer attention and effort to keep the lockfile
  up-to-date.

The Rust Cargo team currently recommends against committing the lockfile
for library crates in version control, but plans to reverse this
  recommendation in the future. You can read the new Cargo
  recommendations in the Nightly version docs:

* https://doc.rust-lang.org/nightly/cargo/faq.html#why-have-cargolock-in-version-control
* Web snapshot in Internet Archive: http://web.archive.org/web/20230921033901/https://doc.rust-lang.org/nightly/cargo/faq.html#why-have-cargolock-in-version-control

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
@andreeaflorescu
Copy link
Member

I was thinking that with a committed lock file we will also get more dependabot PRs because then updates to patch/minor release will also need to be specifically done, they'll no longer be picked up by default. I guess since we're also doing batch dependabot updates that's not such a big concern. WDYT?

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

Successfully merging this pull request may close these issues.

2 participants