#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

new 0.1.1 Apr 19, 2025
0.1.0 Apr 14, 2025

#139 in Cargo plugins

Download history 82/week @ 2025-04-11

82 downloads per month

MIT/Apache

19KB
358 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

License

Licensed under either of

at your option.

Contribution

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–11MB
~110K SLoC