Skip to content
Latchkey

Cargo "multiple packages with the same name" in CI

Two crates in your workspace declare the same package name, or a path dependency collides with a same-named registry crate. Cargo cannot disambiguate which one a name refers to and refuses to build.

What this error means

Resolution fails with two packages named X in this workspace (or found multiple packages matching). It appears after copying a crate, renaming sloppily, or adding a path dep whose name already exists on crates.io.

cargo
error: two packages named `utils` in this workspace:
  /home/runner/work/app/crates/utils/Cargo.toml
  /home/runner/work/app/legacy/utils/Cargo.toml

Common causes

Two workspace members share a name

Each package.name in a workspace must be unique. A copied or leftover crate that kept the original name collides with the real one.

Path crate shadows a registry crate

A local path dependency named the same as a crates.io crate creates an ambiguous reference when both are in the graph.

How to fix it

Rename one of the colliding packages

Give each crate a unique package.name (you can keep the lib name with lib.name if needed).

Cargo.toml
# crates/legacy-utils/Cargo.toml
[package]
name = "legacy-utils"

Remove the stray member from the workspace

If a leftover crate should not be part of the build, drop it from members (or exclude it).

Cargo.toml
[workspace]
members = ["crates/*"]
exclude = ["legacy/utils"]

How to prevent it

  • Keep every package.name in the workspace unique.
  • Avoid path crates that shadow crates.io names.
  • Use workspace.exclude to keep stale copies out of resolution.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →