rust-lang/cargo · error · anyhow::Error
`{key}.workspace = false` is unsupported
Error message
`{key}.workspace = false` is unsupported What it means
Thrown by `Dependency::from_toml` (the editor used by `cargo add`/`cargo rm`) at src/workspace/editor/dependency.rs:318. When a dependency table contains a `workspace` key whose value is `false`, cargo rejects it because `workspace = false` is semantically a no-op — the absence of the key already means "do not inherit from workspace.dependencies". Only the positive `workspace = true` form is meaningful.
Source
Thrown at src/workspace/editor/dependency.rs:318
let mut src = PathSource::new(path);
src.base = base;
if let Some(value) = table.get("version") {
src = src.set_version(value.as_str().ok_or_else(|| {
invalid_type(key, "version", value.type_name(), "string")
})?);
}
src.into()
} else if let Some(version) = table.get("version") {
let src = RegistrySource::new(version.as_str().ok_or_else(|| {
invalid_type(key, "version", version.type_name(), "string")
})?);
src.into()
} else if let Some(workspace) = table.get("workspace") {
let workspace_bool = workspace.as_bool().ok_or_else(|| {
invalid_type(key, "workspace", workspace.type_name(), "bool")
})?;
if !workspace_bool {
anyhow::bail!("`{key}.workspace = false` is unsupported")
}
let src = WorkspaceSource::new();
src.into()
} else {
anyhow::bail!(
"dependency ({key}) specified without \
providing a local path, Git repository, version, or \
workspace dependency to use"
);
};
let registry = if let Some(value) = table.get("registry") {
Some(
value
.as_str()
.ok_or_else(|| invalid_type(key, "registry", value.type_name(), "string"))?
.to_owned(),
)
} else {View on GitHub (pinned to 0e07a15537)
Solutions
- Delete the `workspace = false` pair so the line becomes `foo = "1.0"` (or whatever the real source is).
- If you intended inheritance, change it to `foo = { workspace = true }` and define `foo` under `[workspace.dependencies]` in the workspace root.
Example fix
# before
foo = { workspace = false }
# after
foo = "1.0"
# (or, to inherit)
foo = { workspace = true } Defensive patterns
Strategy: validation
Validate before calling
// before invoking the manifest editor, scrub `workspace = false`
for (_k, item) in doc.as_table().iter() {
if let Some(t) = item.as_table_like() {
if matches!(t.get("workspace").and_then(|v| v.as_bool()), Some(false)) {
// remove or convert before calling Dependency::from_toml
}
}
} Prevention
- Treat `workspace = false` as always redundant — never write it.
- Use `cargo add`/`cargo rm` instead of hand-editing dependency tables.
- Lint manifests in CI for `workspace = false` occurrences.
When it happens
Trigger: A `[dependencies]` entry written as `foo = { workspace = false }`, or `cargo add` leaving behind `{ workspace = false }` in a member Cargo.toml. The branch is reached only when the table has no `git`/`path`/`version` and `table.get("workspace")` yields a bool `false`.
Common situations: Hand-editing a manifest after removing workspace inheritance; tools/generators that emit `workspace = false` defensively; misunderstanding that `false` must be expressed by omitting the key.
Related errors
- `default-features = false` cannot override workspace's `defa
- package `{}` cannot be tested because it requires dev-depend
- {}package(s) `{}` not found in workspace `{}`
- no library targets found in packages: {}
- invalid feature `{}` in required-features of target `{}`: `d
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/f0694d5f41c1071a.json.
Report an issue: GitHub.