cargo-propagate-features 1.0.3

Cargo subcommand to automatically propagate workspace crate features to dependencies
cargo-propagate-features-1.0.3 is not a library.

cargo-propagate-features

Crates.io Documentation CI License: MIT OR Apache-2.0 Downloads

Cargo subcommand to automatically propagate workspace crate features to their dependencies.

What it does

For any crate A with feature X depending on crate B that also has feature X, this tool ensures that crate A's feature X includes "B/X" in its feature dependencies.

This ensures that when you enable a feature on a crate, all its dependencies that have the same feature also get that feature enabled. Without this, enabling a feature might not work correctly because dependencies don't have their corresponding features enabled.

Example

Consider a workspace with three crates:

  • my-app depends on my-library and my-utils
  • All three crates have the same features: backend, cli, desktop, web

When you enable the backend feature on my-app, you typically want the backend features of my-library and my-utils to also be enabled. This tool automatically adds those feature dependencies.

Before running the tool:

# my-app/Cargo.toml
[dependencies]
my-library = { path = "../my-library" }
my-utils = { path = "../my-utils" }

[features]
backend = []      # ❌ Doesn't enable backend features on dependencies
cli = []
desktop = []
web = []

After running the tool:

# my-app/Cargo.toml
[dependencies]
my-library = { path = "../my-library" }
my-utils = { path = "../my-utils" }

[features]
backend = ["my-library/backend", "my-utils/backend"]  # ✅ Now properly propagates
cli = ["my-library/cli", "my-utils/cli"]
desktop = ["my-library/desktop", "my-utils/desktop"]
web = ["my-library/web", "my-utils/web"]

Now when you build with cargo build --features backend, the backend features on my-library and my-utils will also be enabled.

Installation

Using cargo-binstall (Recommended)

First install cargo-binstall if you haven't already:

cargo install cargo-binstall

Then install cargo-propagate-features:

cargo binstall cargo-propagate-features

Using cargo install

cargo install cargo-propagate-features

Usage

From the workspace root:

cargo propagate-features [OPTIONS]

Options

  • --dry-run: Show what would be changed without modifying files
  • --features <FEATURES>: Comma-separated list of features to propagate (default: backend,cli,desktop,web)
  • --workspace-path <PATH>: Path to workspace root or Cargo.toml (optional, defaults to workspace containing the manifest). When using cargo run, you can point to a Cargo.toml file directly.
  • --quiet: Suppress output when there are no changes

The command automatically respects Cargo's standard options when installed and invoked via cargo:

  • --manifest-path <PATH>: Path to Cargo.toml (automatically handled via cargo_metadata)
  • --package <SPEC>: Work on a specific package (if supported)

License

Copyright © 2026 DataRoad Inc, Delaware, USA, trading as Legra.

Licensed under either the MIT license or the Apache License, Version 2.0, at your option.

Nonmutating CI validation

Use cargo propagate-features --check --features web,backend with the workspace's explicit feature policy. Exit 0 means clean; exit 1 means propagation changes are needed. Manifests are unchanged in check mode, including when only removal of hardcoded features is needed. Do not parse human-readable dry-run output to decide CI success.

Renamed dependencies use their manifest alias. Optional dependencies receive alias?/feature, so propagation does not enable a dependency that was otherwise disabled. Existing explicit activation is retained. --version identifies the installed package.