Skip to content

Conversation

@epage
Copy link
Contributor

@epage epage commented Sep 3, 2025

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 epage marked this pull request as draft September 3, 2025 18:24
@rustbot
Copy link
Collaborator

rustbot commented Sep 3, 2025

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 rustbot added Command-package S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 3, 2025
@rustbot

This comment has been minimized.

@epage epage force-pushed the publish-move-crate branch from d742813 to 8cc523d Compare October 3, 2025 16:20
@epage epage force-pushed the publish-move-crate branch from 8cc523d to f932701 Compare November 3, 2025 20:45
@rustbot

This comment has been minimized.

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

If anyone was relying on this behavior of `cargo publish`, it will break
them.
We could avoid this and instead consider the location change to be part
of the opt-in of using `build-dir` (until we make it opt-out).
Note that we expect to be able to change the layouf of content written
to `build-dir` even if users aren't opting in.

On the other hand, this will help identify people relying on
intermediate artifacts.

While there aren't any performance benefits to this, it consolidates all
of the uplifting logic and avoids dealing with overlapping `target_dir`
and `build_dir`.
We could optimize this further by doing a `rename` and only doing a copy
if that fails.
@epage epage force-pushed the publish-move-crate branch 2 times, most recently from 86f048c to 86f6344 Compare November 24, 2025 15:40
@epage epage force-pushed the publish-move-crate branch from 86f6344 to dd06704 Compare December 4, 2025 15:37
@epage epage marked this pull request as ready for review December 4, 2025 15:37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage I am going to do a submodule update today before new nightly branch cutoff. Mainly because of #16337.

Do you want to include this in 1.93 or 1.94? I am fine with either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 releases would be 1.93 but there is no rush on this

@weihanglo weihanglo added this pull request to the merge queue Dec 4, 2025
Merged via the queue into rust-lang:master with commit 2c283a9 Dec 4, 2025
26 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 4, 2025
@epage epage deleted the publish-move-crate branch December 4, 2025 17:30
bors added a commit to rust-lang/rust that referenced this pull request Dec 5, 2025
Update cargo submodule

9 commits in bd979347d814dfe03bba124165dbce9554d0b4d8..2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac
2025-12-02 16:03:50 +0000 to 2025-12-04 16:47:28 +0000
- fix(publish): Move `.crate` out of final artifact location (rust-lang/cargo#15915)
- Remove legacy tmpdir support (rust-lang/cargo#16342)
- Run clippy CI on more targets (rust-lang/cargo#16340)
- feat: support for rustdoc mergeable cross-crate info (rust-lang/cargo#16309)
- fix(timings): unlocked -> unblocked (rust-lang/cargo#16337)
- fix(layout): Put examples in their unit dir in new layout (rust-lang/cargo#16335)
- fix(frontmatter): Restrict code fence length  (rust-lang/cargo#16334)
- Update resolver.md: fix compile errors in pseudocode (rust-lang/cargo#16333)
- fix(fingerprint): clean doc dirs for only requested targets (rust-lang/cargo#16331)

This is best being merged before beta cutoff because rust-lang/cargo#16337 is a nightly regression.
@rustbot rustbot added this to the 1.93.0 milestone Dec 5, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 5, 2025
Update cargo submodule

9 commits in bd979347d814dfe03bba124165dbce9554d0b4d8..2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac
2025-12-02 16:03:50 +0000 to 2025-12-04 16:47:28 +0000
- fix(publish): Move `.crate` out of final artifact location (rust-lang/cargo#15915)
- Remove legacy tmpdir support (rust-lang/cargo#16342)
- Run clippy CI on more targets (rust-lang/cargo#16340)
- feat: support for rustdoc mergeable cross-crate info (rust-lang/cargo#16309)
- fix(timings): unlocked -> unblocked (rust-lang/cargo#16337)
- fix(layout): Put examples in their unit dir in new layout (rust-lang/cargo#16335)
- fix(frontmatter): Restrict code fence length  (rust-lang/cargo#16334)
- Update resolver.md: fix compile errors in pseudocode (rust-lang/cargo#16333)
- fix(fingerprint): clean doc dirs for only requested targets (rust-lang/cargo#16331)

This is best being merged before beta cutoff because rust-lang/cargo#16337 is a nightly regression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants