#member #cargo-workspace #dependencies #common #workspace-root #workspace-members

app cargo-easy-dep

Simplifies dependency management in Rust workspaces by unifying common workspace members' dependencies in workspace

2 releases

Uses new Rust 2024

0.1.1 Apr 19, 2025
0.1.0 Apr 14, 2025

#74 in Cargo plugins

Download history 230/week @ 2025-04-14 28/week @ 2025-04-21

258 downloads per month

MIT/Apache

23KB
411 lines

cargo-easy-dep

Crates.io License: MIT OR Apache-2.0 Rust: 2024 Edition

A cargo subcommand that simplifies dependency management in Rust workspaces by automatically unifying common dependencies at the workspace level.

Overview

In large Rust workspaces, managing dependencies across multiple crates can become cumbersome. cargo-easy-dep analyzes your workspace and:

  1. Identifies dependencies used by multiple workspace members
  2. Adds these common dependencies to the workspace's Cargo.toml
  3. Updates each member's Cargo.toml to use the workspace dependency

This approach reduces duplication, simplifies updates, and ensures version consistency across your workspace.

Installation

cargo install cargo-easy-dep

Usage

From your workspace root directory, run:

cargo easy-dep

Options

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

Examples

Basic Usage

# Run from your workspace root
cargo easy-dep

Customize Minimum Occurrences

Consider all dependencies used by workspace members:

cargo easy-dep --min-occurrences 1

Specify Workspace Root

cargo easy-dep --workspace-root /path/to/my/workspace

Silent Mode

cargo easy-dep --quiet

How It Works

  1. Analyzes your workspace structure using cargo_metadata
  2. Counts the occurrences of each dependency across workspace members
  3. Identifies dependencies used by multiple crates (configurable via --min-occurrences)
  4. Updates the root Cargo.toml to add these dependencies to the [workspace.dependencies] section
  5. Updates each member's Cargo.toml to use workspace = true for these dependencies

Notes

  1. 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.
  2. 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.
  3. There is no difference between '^1.0' and '1.0' in versioning and as cargo-easy-dep uses semver::VersionReq as versioning strategy like what cargo does, you will see '^1.0' in your root workspace Cargo.toml for dependencies versions. (1.0 version used as an example)

License

Licensed under either of:

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.

Dependencies

~3–10MB
~109K SLoC