cargo remove -p <member> <dep> does more than it says: it also prunes the matching entry from the root [workspace.dependencies] block once no member references it any more. This silently breaks the obvious four-step path for migrating a dependency to workspace inheritance.
- Observed on cargo 1.95.0 (
f2d3ce0bd, 2026-03-21)
The broken migration path
The intuitive sequence for moving a dep into workspace inheritance is:
- add to member
- copy the entry up to root
[workspace.dependencies]cargo remove -p <member> <dep>← the entry vanishes here- re-add as
<dep>.workspace = trueStep 3 deletes the workspace entry you just wrote in step 2, because removing it from the member left zero references. Step 4 then fails:
error: `workspace.dependencies` was not definedThe failure surfaces at
cargo check, one step after the actual cause, which is what makes it confusing — the rootCargo.tomllooks like it was never edited.
Fix
Do not route the migration through cargo remove. Write the inheritance into the member manifest by hand:
[dependencies]
grafeo.workspace = trueEdit the member’s [dependencies] directly — replace the version entry with the .workspace = true form in a single edit, so the dependency is never unreferenced and cargo never has cause to prune the root.
For Agents
Rule of thumb:
cargo removeis a workspace-aware garbage collector, not a per-manifest text edit. When restructuring dependencies across a workspace, prefer direct manifest edits — cargo’s cleanup is helpful during genuine removal and actively harmful mid-migration.
Related
- ai-project-brain — the workspace where this was hit, during initial setup
- grafeo-feature-matrix — the other setup-time gotcha from the same session