Skip to content

Introduce --all-features flag to cargo vendor #12596

Open
@collinoc

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:

  1. cargo add tokio --features full
  2. cargo vendor vendor_dir
  3. User uses vendored directory for source replacement
  4. User tries to use tokio features behind mio feature (not under full 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 for tokio in previous example)
  • --all-features=recursive would recursively vendor dependencies for all features for all dependencies (all optional depencies for tokio and mio 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-vendorS-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions