rust-lang/cargo · error
dependency ( ) specified without providing a local path…
Error message
dependency ({key}) specified without providing a local path, Git repository, version, or workspace dependency to use What it means
Thrown by the manifest editor dependency parser when a dependency entry is a table but contains none of the recognized source keys: 'git', 'path', 'version', or 'workspace'. The parser falls through all source-detection branches and hits the final else. It means the dependency was declared as a table yet has no way to locate its code.
Solutions
- Add a 'version' key to the dependency table (e.g. version = "1.0").
- Alternatively add 'path', 'git', or 'workspace = true' to identify the source.
- Check for misspelled source keys (verison, pat, etc.) and correct them.
Example fix
# before
[dependencies]
serde = { features = ["derive"] }
# after
[dependencies]
serde = { version = "1.0", features = ["derive"] } Defensive patterns
Strategy: validation
Validate before calling
fn has_dependency_source(table: &toml_edit::Item) -> bool {
if let Some(t) = table.as_table_like() {
return t.contains_key("git") || t.contains_key("path")
|| t.contains_key("version") || t.contains_key("workspace");
}
false
}
// assert before calling Dependency::from_toml Type guard
fn is_complete_dependency_table(table: &dyn toml_edit::TableLike) -> bool {
["git","path","version","workspace"].iter().any(|k| table.contains_key(*k))
} Prevention
- Require a version/path/git/workspace key in every dependency table before parsing.
- Use a manifest linter (cargo-deny, taplo) to catch source-less dependencies.
- When generating manifests programmatically, assert each dep has a source field.
When it happens
Trigger: Calling Dependency::from_toml on a TOML table like { optional = true } or { features = ["derive"] } that omits every source key. The editor tries git, then path, then version, then workspace, then bails.
Common situations: A developer writes [dependencies.serde] with only feature/optional flags and forgets the version. A migration tool strips a version field while preserving the table shape. Typos like 'verison' instead of 'version' leave no recognized source.
Related errors
- dependency ( ) specified without providing a local path…
- ` .workspace = false` is unsupported
- Unrecognized` dependency entry format for
- Use of `default_features` in
- can only edit absolute paths, got
AI-assisted analysis of rust-lang/cargo@eb98b54bc9 (2026-08-11).
Data as JSON: /api/errors/07cc8a9659c48a31.
Report an issue: GitHub.
Appendix: source
Thrown at src/workspace/editor/dependency.rs:323
})?);
}
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 {
None
};
let default_features = table.get("default-features").and_then(|v| v.as_bool());
if table.contains_key("default_features") {View on GitHub (pinned to eb98b54bc9)