Description
Problem
When using cargo vendor, the only transitive dependencies that get vendored are the ones of enabled features at the original time of vendoring. This is an issue when a user that only has access to the vendored crates later tries to enable a feature of a crate that was not originally enabled. Example flow:
cargo add tokio --features full
cargo vendor vendor_dir
- User uses vendored directory for source replacement
- User tries to use tokio features behind
mio
feature (not underfull
feature flag), but transitive dependencies were not included in vendored directory and is unable to build
Proposed Solution
I propose introducing an --all-features
flag to cargo vendor
that would vendor all optional dependencies behind any feature flags for any dependencies of a project. This is simply a convenience so that not all features have to be manually specified.
Another possibility would be to have different levels for vendoring for "all features":
--all-features=top
would only vendor dependencies for all features for top level dependencies (all optional dependencies fortokio
in previous example)--all-features=recursive
would recursively vendor dependencies for all features for all dependencies (all optional depencies fortokio
andmio
and so on, in previous example)
Notes
Cargo seems to have an all-features flag that is similar to what I am thinking of.
I'd be glad to contribute to this! 😃
Activity