-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(publish): Don't generate final artifacts #15910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to update the doc as well https://doc.rust-lang.org/1.89.0/cargo/reference/build-cache.html.
src/cargo/ops/cargo_package/mod.rs
Outdated
let tmp = format!(".{}", filename); | ||
dir.open_rw_exclusive_create(&tmp, gctx, "package scratch space")? | ||
}; | ||
let dir = ws.build_dir().join("package").join("tmp-crate"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
73557ed
to
82a42dd
Compare
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
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)
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)
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)
What does this PR try to resolve?
When splitting
build-dir
out oftarget-dir
(see #14125), we kept.crate
files as final artifacts ofcargo package
. However, that also made them final artifacts ofcargo publish
when the side effect of that should be the publish operation.This changes things so that we instead package within
build-dir
andcargo package
then uplifts these totarget-dir
.Behavior change: when running
cargo publish
withoutbuild-dir
set,target/package/*.crate
will be moved totarget/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 thebuild-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` @ 💬