rust-lang/cargo · error · anyhow::Error
Unrecognized` dependency entry format for `{key}`
Error message
Unrecognized` dependency entry format for `{key}` What it means
Thrown by `Dependency::from_toml` (editor) at src/workspace/editor/dependency.rs:380 — the final `else` branch of the parser. It fires when the TOML value for a dependency key is neither a plain version string nor a table-like item (e.g. it is an integer, float, bool, array, or datetime). A dependency must be `name = "version"` or `name = { ... }`.
Source
Thrown at src/workspace/editor/dependency.rs:380
};
let optional = table.get("optional").and_then(|v| v.as_bool());
let public = table.get("public").and_then(|v| v.as_bool());
let dep = Self {
name,
optional,
public,
features,
default_features,
inherited_features: None,
source: Some(source),
registry,
rename,
};
Ok(dep)
} else {
anyhow::bail!("Unrecognized` dependency entry format for `{key}");
}
}
/// Get the dependency name as defined in the manifest,
/// that is, either the alias (rename field if Some),
/// or the official package name (name field).
pub fn toml_key(&self) -> &str {
self.rename().unwrap_or(&self.name)
}
/// Convert dependency to TOML.
///
/// Returns a tuple with the dependency's name and either the version as a
/// `String` or the path/git repository as an `InlineTable`.
/// (If the dependency is set as `optional` or `default-features` is set to
/// `false`, an `InlineTable` is returned in any case.)
///
/// # PanicView on GitHub (pinned to 0e07a15537)
Solutions
- Quote the version: `foo = "1.0"`.
- If you need options, use a table: `foo = { version = "1.0", optional = true }`.
- Validate the manifest with `toml-edit`/`cargo check` after editing to catch the type mismatch early.
Example fix
# before foo = 1.0 # after foo = "1.0"
Defensive patterns
Strategy: type-guard
Type guard
fn is_valid_dep_item(item: &toml_edit::Item) -> bool {
item.as_str().is_some() || item.as_table_like().is_some()
}
// assert is_valid_dep_item(&doc["dependencies"]["foo"]) before parsing Prevention
- Dependency values must be a quoted string or a table — never a bare number/bool/array.
- Run `cargo check` after generating manifests from scripts/templates.
- Quote all version literals.
When it happens
Trigger: Entries such as `foo = 1` (bare integer), `foo = true`, `foo = ["1.0"]`, or `foo = 1.0`. The `if let Some(version) = item.as_str()` and `else if let Some(table) = item.as_table_like()` branches both fail, dropping into the catch-all.
Common situations: Omitting quotes around a version (`foo = 1.0` instead of `foo = "1.0"`); malformed YAML-to-TOML conversion; LLM-generated manifests.
Related errors
- Deprecated dependency sections are unsupported: {}
- invalid feature `{}` in required-features of target `{}`: `d
- all dependencies must have a version requirement specified w
- '{}' is not a valid artifact specifier
- Cannot specify both 'bin' and 'bin:<name>' binary artifacts,
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/4f044d3d73931be2.json.
Report an issue: GitHub.