Skip to content

Cargo.lock is modified after running cargo package #8610

Closed as not planned
Closed as not planned
@bk2204

Description

@bk2204

Problem
When using a Cargo.lock generated by 1.24.1, running cargo package modifies Cargo.lock and then fails without packaging anything. It's unexpected for cargo to modify any version-controlled file, and then to fail when the file has not been modified by the user. If the file is well-formed and semantically meaningful, it should be accepted without change by cargo package. If it is not, cargo should abort without modifying the file.

My projects have a strict version compatibility requirement so Cargo.lock is built with an appropriate version of the Rust toolchain. Because there's no way to explicitly pin packages to minimum versions or to force versions of packages that work with a specific Rust version, the building of Cargo.lock has to be done with an older version of the toolchain and hand-editing, so using a newer version of cargo to generate the file isn't a possibility here.

Steps

  1. git clone https://github.com/bk2204/muter
  2. cd muter
  3. cargo package
  4. git diff

Possible Solution(s)
Avoid adding the generated header unless the Cargo.lock is intentionally regenerated or is missing.

Notes

Output of cargo version:
cargo 1.45.1 (f242df6 2020-07-22)

This is with Rust 1.45.2 stable as a toolchain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lockfileArea: Cargo.lock issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions