-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
cargo vendor
pull large amounts of unrelated crates.
#11929
Comments
Related: #7058 |
Good reference, thanks. They're slightly difference scenarios, but hopefully a common fix can address both. |
Any ideas how to make these show up in |
I wasn't sure, so I ran
Looks like |
Thanks! |
It seems that if all my top-level dependencies are defined as |
Going to close this as a duplicate of #7058. They seem best to be discussed as a whole. Let us know if this is wrong and we can consider reopen. |
Sure, hopefully a common solution will fix both issues. |
hi @weihanglo o/ I believe this issue is broader than single platform vendored packages, like #7058. If you make a simple hello world package with a dependency to This issue seems to be described on https://wiki.ubuntu.com/RustCodeInMain
Possibly an AST could determine which dependencies the base package actually uses, to debloat vendored packages. |
@eslerm |
@weihanglo could this issue please be re-opened as unresolved? I understand that this feature might not be added. By having an accurate issue, distros with vendored rust packages can be pointed here 🙏 |
They can still be pointed here. Re-opening miscommunicates our intent with the community and makes it harder to track our backlog. |
See #7058
|
Thanks everyone. #7058 has a narrower scope and doesn't fully overlap with this one, but resolving it would help immensely. (A lot of bandwidth is being spent vendoring unnecessary Windows crates for Linux software.) My hunch is that a secondary tool will be needed to lint the results of A colleague pointed out that an AST would be complicated, as different cfg() parameters would need to be accounted for and that projects might need to be patched to use edit: https://poignardazur.github.io/2021/02/15/rust-wishlist-better-cfg/ |
Gnome snapshot removed over 200M of unnecessary vendoring with /~https://github.com/coreos/cargo-vendor-filterer https://gitlab.gnome.org/GNOME/snapshot/-/commit/e52debce683338bce43a6150edb07e8c30efc617 |
Problem
When I run
cargo vendor
, it downloads a huge amount of crates that are not dependencies for my codebase. The total size of thevendor
directory is 230M, but the unnecessary dependencies are over 182M (slightly over 80%).cargo tree
confirms that none of these are [transitive] dependencies for my project.Most of these seem to be
winapi
and its subtree of dependencies. However, my code has nothing windows-related, and probably won't even run on windows. I suspect, however, that cargo by default assumes that it does, and that some transitive dependency depends on one of these (Although I'm not sure whycargo tree
won't list them).Steps
git clone https://git.sr.ht/~whynothugo/shotman
cd shotman
cargo vendor
Possible Solution(s)
Does cargo has a way of determining on which targets my code actually builds? This would be the ideal approach so it can just ignore unnecessary dependencies. I don't think my code would build on windows, since it uses some basic things like file-descriptors and other Unix-only features.
Otherwise, being able to explicitly specify "this won't build on windows" would be useful to avoid downloading all the dependencies that are specific for that target.
Notes
Since
cargo tree
doesn't list these crates as dependencies, there's also no obvious way for me to even figure out where they're coming from.Version
The text was updated successfully, but these errors were encountered: