cargo icon indicating copy to clipboard operation
cargo copied to clipboard

fix(publish): Move `.crate` out of final artifact location

Open epage opened this issue 4 months ago • 3 comments

When target_dir == build_dir, ensure cargo publish doesn't put intermediate artifacts in the final artifact location of cargo package.

What does this PR try to resolve?

In #15910, users could identify that .crate files from cargo publish are not final artifacts by setting a custom build-dir. This extends that to all users, ie when build-dir = target-dir (the default currently), making it clear that these files are internal.

This also cleans things up by consolidating all of the uplifting logic and avoids dealing with overlapping target_dir and build_dir.

How to test and review this PR?

Notes

We could optimize this further by doing a rename and only doing a copy if that fails, effectively a rename_or_copy as opposed to our hardlink_or_copy we normally use for uplifting. The difference is that we don't do change tracking for .crate files but fully re-generate, so we don't benefit from keeping the .crate around in the original location.

epage avatar Sep 03 '25 18:09 epage

r? @weihanglo

rustbot has assigned @weihanglo. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Sep 03 '25 18:09 rustbot

:umbrella: The latest upstream changes (possibly 9191c77aa157eff5fb5a244908e0c8ddac74aaeb) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Oct 02 '25 19:10 rustbot

:umbrella: The latest upstream changes (possibly 8e43074b2365e1f908570d7f5c2ef76b19d1133c) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Nov 23 '25 03:11 rustbot