Skip to content

vendor: add summary output for crates vendored#16646

Closed
raushan728 wants to merge 1 commit intorust-lang:masterfrom
raushan728:feature/vendor-summary-output
Closed

vendor: add summary output for crates vendored#16646
raushan728 wants to merge 1 commit intorust-lang:masterfrom
raushan728:feature/vendor-summary-output

Conversation

@raushan728
Copy link
Copy Markdown
Contributor

Adds a final status message to 'cargo vendor' showing the count of crates vendored and the destination directory. This improves consistency with other commands like 'cargo install'

@rustbot rustbot added Command-vendor S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 15, 2026

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

Comment thread src/cargo/ops/vendor.rs
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While this change might be simple and straightforwards, our contributing guideline encourages starting from an issue and discussion first before posting a pull request: https://doc.crates.io/contrib/process/working-on-cargo.html#before-hacking-on-cargo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that i am still learning the workflow here. I'll make sure to start with an issue next time

Comment thread src/cargo/ops/vendor.rs
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adds a final status message to 'cargo vendor' showing the count of crates vendored and the destination directory. This improves consistency with other commands like 'cargo install'

I personally don't immediately see the value of consistency here. Other maintainers may have different opinions though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For example, count of binaries installed via cargo install is essentially as we might not want to accidentally install extra bins. But do people really know about how many dependencies they vendor? What is the actual summary people want to know when vendoring. This might be worthy some level of discussions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought a final confirmation would be helpful for large workspaces, but I'm open to suggestions if you think the summary should be different or is unnecessary

Comment thread tests/testsuite/vendor.rs Outdated
Package::new("bar", "0.1.0").publish();

p.cargo("vendor --respect-source-config")
.with_stderr_contains("[..]Vendored 1 crates into [..]vendor")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We recommend snapshot testing with with_stderr_data method as the primary way to assert snapshot. See https://doc.crates.io/contrib/tests/writing.html

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip I've updated the test to use with_stderr_data and snapshot matching

@raushan728
Copy link
Copy Markdown
Contributor Author

raushan728 commented Feb 15, 2026

hi @weihanglo fixed the tests and logic. also, sorry for skipping the issue process i am still learning the workflow. plz take a look

@raushan728 raushan728 force-pushed the feature/vendor-summary-output branch from 6134403 to a06c1d1 Compare May 5, 2026 09:40
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Copy link
Copy Markdown
Member

@0xPoe 0xPoe left a comment

Choose a reason for hiding this comment

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

Thanks!

Not sure if it's really worth adding it, as once you vendor all your crates, all the code will likely be checked into the VCS. You can easily track how many and which crates you have vendored. Especially for large workspaces, I guess this message may not be that helpful since we will vendor a lot of content.

If they want to know how many crates they vendored, they can simply count the directory count. (I'm not sure in what situation this information would be necessary.)

At least for go mod vendor -v, it does not have this kind of summary.

So I personally would prefer not to add it.

View changes since this review

Comment thread tests/testsuite/vendor.rs
}

#[cargo_test]
fn vendor_summary_output() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should try to vendor multiple crates in this test case. Otherwise, the tested logic is already covered by other tests, as you can see those tests already include Vendored 1 crate into vendor in their test output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the test to vendor multiple crates

@raushan728 raushan728 force-pushed the feature/vendor-summary-output branch from a06c1d1 to 0483c12 Compare May 6, 2026 06:08
@raushan728
Copy link
Copy Markdown
Contributor Author

Thanks!

Not sure if it's really worth adding it, as once you vendor all your crates, all the code will likely be checked into the VCS. You can easily track how many and which crates you have vendored. Especially for large workspaces, I guess this message may not be that helpful since we will vendor a lot of content.

If they want to know how many crates they vendored, they can simply count the directory count. (I'm not sure in what situation this information would be necessary.)

At least for go mod vendor -v, it does not have this kind of summary.

So I personally would prefer not to add it.

View changes since this review

That makes sense. My intention here was mainly to provide a small UX improvement and keep it consistent with other commands like cargo install that show a summary.

I agree that for large workspaces it might not add much value, but it could still be useful in smaller cases or scripting scenarios.

If you think it's not worth showing by default, we can drop it.

@raushan728 raushan728 requested review from 0xPoe and weihanglo May 6, 2026 06:17
@weihanglo
Copy link
Copy Markdown
Member

scripting scenarios

We do not recommend using status messages for scripting. They have no stability guarantee.

Comment thread tests/testsuite/vendor.rs
Vendoring baz v0.1.0 ([..]baz-0.1.0) to vendor/baz
Vendoring qux v0.1.0 ([..]qux-0.1.0) to vendor/qux
To use vendored sources, add this to your .cargo/config.toml for this project:

Copy link
Copy Markdown
Member

@weihanglo weihanglo May 6, 2026

Choose a reason for hiding this comment

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

The other issue of this is that stout would have a example config output mixing with the added summary status in stderr.

Have you run it end-to-end and how would it look like? I assume it might be a bit messy though

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have you run it end-to-end and how would it look like? I assume it might be a bit messy though

I ran it end-to-end, here's the actual output

/tmp/test-cargo-build-target/debug/cargo vendor

    Updating crates.io index
     Locking 18 packages to latest compatible versions
      Adding rand v0.8.6 (available: v0.10.1)
 Downloading crates ...
  Downloaded wasi v0.11.1+wasi-snapshot-preview1
  Downloaded rand v0.8.6
   Vendoring cfg-if v1.0.4 (...) to /tmp/test-vendor/vendor/cfg-if
   Vendoring getrandom v0.2.17 (...) to /tmp/test-vendor/vendor/getrandom
   Vendoring libc v0.2.186 (...) to /tmp/test-vendor/vendor/libc
   Vendoring log v0.4.29 (...) to /tmp/test-vendor/vendor/log
   Vendoring ppv-lite86 v0.2.21 (...) to /tmp/test-vendor/vendor/ppv-lite86
   Vendoring proc-macro2 v1.0.106 (...) to /tmp/test-vendor/vendor/proc-macro2
   Vendoring quote v1.0.45 (...) to /tmp/test-vendor/vendor/quote
   Vendoring rand v0.8.6 (...) to /tmp/test-vendor/vendor/rand
   Vendoring rand_chacha v0.3.1 (...) to /tmp/test-vendor/vendor/rand_chacha
   Vendoring rand_core v0.6.4 (...) to /tmp/test-vendor/vendor/rand_core
   Vendoring serde v1.0.228 (...) to /tmp/test-vendor/vendor/serde
   Vendoring serde_derive v1.0.228 (...) to /tmp/test-vendor/vendor/serde_derive
   Vendoring syn v2.0.117 (...) to /tmp/test-vendor/vendor/syn
   Vendoring unicode-ident v1.0.24 (...) to /tmp/test-vendor/vendor/unicode-ident
   Vendoring wasi v0.11.1+wasi-snapshot-preview1 (...) to /tmp/test-vendor/vendor/wasi
   Vendoring zerocopy v0.8.48 (...) to /tmp/test-vendor/vendor/zerocopy
   Vendoring zerocopy-derive v0.8.48 (...) to /tmp/test-vendor/vendor/zerocopy-derive
To use vendored sources, add this to your .cargo/config.toml for this project:

[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"

    Vendored 18 crates into vendor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The output looks clean config snippet appears first, then the summary line at the end. No messy interleaving in practice. Happy to keep or drop based on your call.

Copy link
Copy Markdown
Member

@weihanglo weihanglo May 6, 2026

Choose a reason for hiding this comment

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

I think that is interleaving apparently from an end-user perspective.


Since two maintainer have asked about the actual scenario here, and it seems pretty vague ("it could still be useful" without actual cases), I suggest we close this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can move to an issue if you have your use cases in mind, and we discuss :)

@weihanglo weihanglo closed this May 6, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 6, 2026
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.

4 participants