A cargo subcommand that simplifies dependency management in Rust workspaces by automatically unifying common dependencies at the workspace level.
In large Rust workspaces, managing dependencies across multiple crates can become cumbersome. cargo-easy-dep
analyzes your workspace and:
- Identifies dependencies used by multiple workspace members
- Adds these common dependencies to the workspace's
Cargo.toml
- Updates each member's
Cargo.toml
to use the workspace dependency
This approach reduces duplication, simplifies updates, and ensures version consistency across your workspace.
cargo install cargo-easy-dep
From your workspace root directory, run:
cargo easy-dep
Options:
-m, --min-occurrences <MIN_OCCURRENCES>
Minimum number of occurrences to consider a dependency common [env: CARGO_EASY_DEP_MIN_OCCURRENCES=] [default: 2]
-w, --workspace-root <WORKSPACE_ROOT>
Path to workspace root (defaults to current directory) [env: CARGO_EASY_DEP_WORKSPACE_ROOT=]
-q, --quiet
Suppress all output [env: CARGO_EASY_DEP_QUIET=]
-h, --help
Print help
-V, --version
Print version
# Run from your workspace root
cargo easy-dep
Consider all dependencies used by workspace members:
cargo easy-dep --min-occurrences 1
cargo easy-dep --workspace-root /path/to/my/workspace
cargo easy-dep --quiet
- Analyzes your workspace structure using
cargo_metadata
- Counts the occurrences of each dependency across workspace members
- Identifies dependencies used by multiple crates (configurable via
--min-occurrences
) - Updates the root
Cargo.toml
to add these dependencies to the[workspace.dependencies]
section - Updates each member's
Cargo.toml
to useworkspace = true
for these dependencies
- The workspace default-features is problematic, so
cargo-easy-dep
will disable default-features for all dependencies in the workspace and enable them based on each member's preferences. This disabling has been done without diffing and it gives maintainers better visibility by explicitly indicating the features without falling into the mentioned issue. - Only the first dependency version seen will be used in the workspace dependencies; tune the version based on your requirements in the workspace
Cargo.toml
. - There is no difference between '^1.0' and '1.0' in versioning and as
cargo-easy-dep
usessemver::VersionReq
as versioning strategy like whatcargo
does, you will see '^1.0' in your root workspaceCargo.toml
for dependencies versions. (1.0
version used as an example)
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.