Skip to content

Dirty Cargo.lock file reported on package/publish even if in .gitignore #15339

Closed
@DaniPopes

Description

@DaniPopes

Problem

Cargo throws an error when trying to publish/package alloy-rs/core on nightly (cargo 1.87.0-nightly (6cf826701 2025-03-14)), while it works fine on stable (1.85).

This breaks our cargo-release workflow, and I don't really understand this error since Cargo.lock is not dirty, is in .gitignore, and also adding it to Cargo.toml package.exclude doesn't help.

Bisected to nightly-2025-03-11 -> rust-lang/rust#138200 -> probably #15276.

Steps

cd /tmp
git clone https://github.com/alloy-rs/core.git alloy-core
# git checkout 5d9b4f22a9091749e87d89058185dd8cf5a03fa2
cd ./alloy-core

args=(package --list)
# No Cargo.lock
cargo +stable "${args[@]}"  # OK
cargo +nightly "${args[@]}" # OK

# Generate Cargo.lock, but still ignored by git
cargo generate-lockfile
cargo +stable "${args[@]}"  # OK
cargo +nightly "${args[@]}" # Fails with:
error: 1 files in the working directory contain changes that were not yet committed into git:

Cargo.lock

to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.87.0-nightly (6cf826701 2025-03-14)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions