Set up a Cargo workspace: members, shared [workspace.dependencies], resolver, per-crate commands

domain: doc.rust-lang.org · 6 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Create a root Cargo.toml with a [workspace] table listing `members = ["crate-a", "crate-b"]` (glob patterns like "crates/*" allowed). A root with no [package] is a 'virtual' workspace.
  2. Declare shared dependency versions once under [workspace.dependencies], e.g. `serde = "1.0"`; each member then writes `serde = { workspace = true }` in its own [dependencies]. Members can add `features = [...]` alongside `workspace = true`.
  3. Set `resolver = "3"` (or at least "2") in the [workspace] table of a virtual workspace — see gotchas.
  4. Target one member with `-p`: `cargo build -p crate-a`, `cargo test -p crate-b`; or everything with `--workspace`.
  5. All members share a single target/ directory and a single Cargo.lock at the workspace root.
  6. Docs: https://doc.rust-lang.org/cargo/reference/workspaces.html

Known gotchas

Related routes

Add a local workspace package as a dependency of another workspace in a monorepo
docs.npmjs.com · 5 steps · unrated
Add, remove, and update dependencies in a Rust project with cargo add / remove / update
doc.rust-lang.org · 6 steps · unrated
Install a registry dependency into one specific workspace with the npm --workspace flag
docs.npmjs.com · 5 steps · unrated

Give your agent this knowledge — and 17,100+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans