Problem
When cargo package is run, the package is built in build-dir and uplifted to artifact-dir.
There appears to be a bug that is causing Cargo to think that build-dir is the target-dir so it locks that directory.
When these directories are the same (the default) this is not an issue, but when they are different the lock is only taken in the build-dir.
Internally, Cargo uses an ephemeral workspace which I believe is probably the issue.
I suspect the issue is with this line which was changed when we separated build-dir and target-dir
https://github.com/ranger-ross/cargo/blob/708100e0d0fe64ad66e05dc5a19110936a5ca4b1/src/cargo/ops/cargo_package/verify.rs#L72
Steps
cargo new not-locking; cd not-locking;
CARGO_BUILD_BUILD_DIR=build cargo package --allow-dirty
tree -a target/
target/
├── CACHEDIR.TAG
└── package
└── not-locking-0.1.0.crate
# Note the lack of a `.cargo-lock`
Possible Solution(s)
Always lock the target-dir when running cargo package
Notes
No response
Version
cargo 1.93.0 (083ac5135 2025-12-15)
release: 1.93.0
commit-hash: 083ac5135f967fd9dc906ab057a2315861c7a80d
commit-date: 2025-12-15
host: x86_64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.15.0-DEV (sys:0.4.83+curl-8.15.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Fedora 43.0.0 [64-bit]
Problem
When
cargo packageis run, the package is built inbuild-dirand uplifted toartifact-dir.There appears to be a bug that is causing Cargo to think that
build-diris thetarget-dirso it locks that directory.When these directories are the same (the default) this is not an issue, but when they are different the lock is only taken in the
build-dir.Internally, Cargo uses an ephemeral workspace which I believe is probably the issue.
I suspect the issue is with this line which was changed when we separated
build-dirandtarget-dirhttps://github.com/ranger-ross/cargo/blob/708100e0d0fe64ad66e05dc5a19110936a5ca4b1/src/cargo/ops/cargo_package/verify.rs#L72
Steps
Possible Solution(s)
Always lock the target-dir when running
cargo packageNotes
No response
Version