Skip to content

Conversation

epage
Copy link
Contributor

@epage epage commented Sep 2, 2025

What does this PR try to resolve?

When splitting build-dir out of target-dir (see #14125), we kept .crate files as final artifacts of cargo package. However, that also made them final artifacts of cargo publish when the side effect of that should be the publish operation.

This changes things so that we instead package within build-dir and cargo package then uplifts these to target-dir.

Behavior change: when running cargo publish without build-dir set, target/package/*.crate will be moved to target/package/tmp-crate/*.crate. This should be fine as its an intermediate artifact but there is a risk that this can break someone who did not realize that. Part of the reason for making the build-dir / target-dir split is to make our intermediate/final artifact intent clearer. We did intend to be a transition period before changing things, like with #15010. I'm assuming its fine that we don't have a transition period here.

How to test and review this PR?

Notes

This was discussed at #t-cargo > `-Zbuild-dir` and `cargo publish` / `cargo package` @ 💬

@rustbot
Copy link
Collaborator

rustbot commented Sep 2, 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 2, 2025
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

let tmp = format!(".{}", filename);
dir.open_rw_exclusive_create(&tmp, gctx, "package scratch space")?
};
let dir = ws.build_dir().join("package").join("tmp-crate");
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit unsure about adding this tmp-crate. From the doc

Contains the output of the cargo package and cargo publish commands.

which means something is there, and it was not clear whether they were intermediate or final artifacts. To minimize the impact, is there a way to do this without the new tmp-crate directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have tmp-registry and the decompressed directories in there.

Is the concern about mixing intermediate and final artifacts in similar locations? We can split that but since its larger than just this, should we split this out?

Copy link
Member

Choose a reason for hiding this comment

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

The concern is people already relying on the package directory layout with cargo publish. While that is not intended, the existing doc putting package and publish together makes them looks like the same. Should we give people one more release to adjust?
We could include a note in the changelog saying this will change in the next release even you are not using build.build-dir. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fine if we want more of a transition. I've dropped the last commit from this PR which means that by default cargo publish will still output .crate files in the same spot and it will only change when build-dir is overridden.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Should probably track it somewhere so when a new nightly branches off we can add the commit back

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll post a draft PR once this is merged.

If we want a transition period, we likely will want more than one release.

@epage epage force-pushed the publish branch 2 times, most recently from 73557ed to 82a42dd Compare September 3, 2025 16:57
@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Sep 3, 2025
@weihanglo weihanglo added this pull request to the merge queue Sep 3, 2025
Merged via the queue into rust-lang:master with commit 78a5531 Sep 3, 2025
25 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 3, 2025
bors added a commit to rust-lang/rust that referenced this pull request Sep 3, 2025
Update cargo submodule

9 commits in a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd9..78a5531ed6608192b5f97eda64ba6e1f6a633eff
2025-08-26 23:05:12 +0000 to 2025-09-03 17:46:38 +0000
- fix(publish): Don't generate final artifacts (rust-lang/cargo#15910)
- chore: Address most typos (rust-lang/cargo#15911)
- chore(deps): update rust crate annotate-snippets to 0.12.1 (rust-lang/cargo#15909)
- test(script): Switch frontmatter tests to end-to-end (rust-lang/cargo#15899)
- chore: fix some typos and grammar (rust-lang/cargo#15905)
- Update dependencies (rust-lang/cargo#15904)
- feat: Don't stop at first error when emitting lints and warnings (rust-lang/cargo#15889)
- fix(cli): Show the bad manifest path (rust-lang/cargo#15896)
- chore(deps): update rust crate tracing-subscriber to v0.3.20 [security] (rust-lang/cargo#15898)

r? ghost
bors added a commit to rust-lang/rust that referenced this pull request Sep 4, 2025
Update cargo submodule

12 commits in a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd9..761c4658d0079d607e6d33cf0c060e61a617cad3
2025-08-26 23:05:12 +0000 to 2025-09-04 01:25:01 +0000
- refactor(shell): Prepare for `Report`s being generated in more places (rust-lang/cargo#15920)
- refactor(frontmatter): Pull out as a dedicated mod (rust-lang/cargo#15914)
- chore: downgrade to libc@0.2.174 (rust-lang/cargo#15918)
- fix(publish): Don't generate final artifacts (rust-lang/cargo#15910)
- chore: Address most typos (rust-lang/cargo#15911)
- chore(deps): update rust crate annotate-snippets to 0.12.1 (rust-lang/cargo#15909)
- test(script): Switch frontmatter tests to end-to-end (rust-lang/cargo#15899)
- chore: fix some typos and grammar (rust-lang/cargo#15905)
- Update dependencies (rust-lang/cargo#15904)
- feat: Don't stop at first error when emitting lints and warnings (rust-lang/cargo#15889)
- fix(cli): Show the bad manifest path (rust-lang/cargo#15896)
- chore(deps): update rust crate tracing-subscriber to v0.3.20 [security] (rust-lang/cargo#15898)
@rustbot rustbot added this to the 1.91.0 milestone Sep 4, 2025
@epage epage deleted the publish branch September 4, 2025 13:38
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 5, 2025
Update cargo submodule

12 commits in a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd9..761c4658d0079d607e6d33cf0c060e61a617cad3
2025-08-26 23:05:12 +0000 to 2025-09-04 01:25:01 +0000
- refactor(shell): Prepare for `Report`s being generated in more places (rust-lang/cargo#15920)
- refactor(frontmatter): Pull out as a dedicated mod (rust-lang/cargo#15914)
- chore: downgrade to libc@0.2.174 (rust-lang/cargo#15918)
- fix(publish): Don't generate final artifacts (rust-lang/cargo#15910)
- chore: Address most typos (rust-lang/cargo#15911)
- chore(deps): update rust crate annotate-snippets to 0.12.1 (rust-lang/cargo#15909)
- test(script): Switch frontmatter tests to end-to-end (rust-lang/cargo#15899)
- chore: fix some typos and grammar (rust-lang/cargo#15905)
- Update dependencies (rust-lang/cargo#15904)
- feat: Don't stop at first error when emitting lints and warnings (rust-lang/cargo#15889)
- fix(cli): Show the bad manifest path (rust-lang/cargo#15896)
- chore(deps): update rust crate tracing-subscriber to v0.3.20 [security] (rust-lang/cargo#15898)
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 8, 2025
Update cargo submodule

12 commits in a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd9..761c4658d0079d607e6d33cf0c060e61a617cad3
2025-08-26 23:05:12 +0000 to 2025-09-04 01:25:01 +0000
- refactor(shell): Prepare for `Report`s being generated in more places (rust-lang/cargo#15920)
- refactor(frontmatter): Pull out as a dedicated mod (rust-lang/cargo#15914)
- chore: downgrade to libc@0.2.174 (rust-lang/cargo#15918)
- fix(publish): Don't generate final artifacts (rust-lang/cargo#15910)
- chore: Address most typos (rust-lang/cargo#15911)
- chore(deps): update rust crate annotate-snippets to 0.12.1 (rust-lang/cargo#15909)
- test(script): Switch frontmatter tests to end-to-end (rust-lang/cargo#15899)
- chore: fix some typos and grammar (rust-lang/cargo#15905)
- Update dependencies (rust-lang/cargo#15904)
- feat: Don't stop at first error when emitting lints and warnings (rust-lang/cargo#15889)
- fix(cli): Show the bad manifest path (rust-lang/cargo#15896)
- chore(deps): update rust crate tracing-subscriber to v0.3.20 [security] (rust-lang/cargo#15898)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants