{"id":"07cc8a9659c48a31","repo":"rust-lang/cargo","slug":"dependency-key-specified-without-providing-a-l","errorCode":null,"errorMessage":"dependency ({key}) specified without providing a local path, Git repository, version, or workspace dependency to use","messagePattern":"dependency \\((.+?)\\) specified without providing a local path, Git repository, version, or workspace dependency to use","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/workspace/editor/dependency.rs","lineNumber":323,"sourceCode":"                        })?);\n                    }\n                    src.into()\n                } else if let Some(version) = table.get(\"version\") {\n                    let src = RegistrySource::new(version.as_str().ok_or_else(|| {\n                        invalid_type(key, \"version\", version.type_name(), \"string\")\n                    })?);\n                    src.into()\n                } else if let Some(workspace) = table.get(\"workspace\") {\n                    let workspace_bool = workspace.as_bool().ok_or_else(|| {\n                        invalid_type(key, \"workspace\", workspace.type_name(), \"bool\")\n                    })?;\n                    if !workspace_bool {\n                        anyhow::bail!(\"`{key}.workspace = false` is unsupported\")\n                    }\n                    let src = WorkspaceSource::new();\n                    src.into()\n                } else {\n                    anyhow::bail!(\n                        \"dependency ({key}) specified without \\\n                        providing a local path, Git repository, version, or \\\n                        workspace dependency to use\"\n                    );\n                };\n            let registry = if let Some(value) = table.get(\"registry\") {\n                Some(\n                    value\n                        .as_str()\n                        .ok_or_else(|| invalid_type(key, \"registry\", value.type_name(), \"string\"))?\n                        .to_owned(),\n                )\n            } else {\n                None\n            };\n\n            let default_features = table.get(\"default-features\").and_then(|v| v.as_bool());\n            if table.contains_key(\"default_features\") {","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/workspace/editor/dependency.rs#L305-L341","documentation":"Thrown by `Dependency::from_toml` (editor) at src/workspace/editor/dependency.rs:323 when a dependency table provides none of the recognized source keys (`git`, `path`, `version`, or `workspace`). Without one of these cargo cannot determine where to fetch the dependency, so parsing aborts.","triggerScenarios":"An entry like `foo = { optional = true }`, `foo = { features = [\"a\"] }`, or `foo = {}` — a table with only metadata keys and no source. Reached only when all four source branches (`git`/`path`/`version`/`workspace`) are absent.","commonSituations":"Forgetting the version after adding optional/features; partial edits by `cargo add` interrupted mid-write; migrating a dependency and deleting the version line by accident.","solutions":["Add a source: a version `foo = { version = \"1.0\", optional = true }`, a path, a git URL, or `workspace = true`.","If you only wanted metadata, the dependency still needs a source — supply the registry version.","Re-run `cargo add foo@1.0` to regenerate a well-formed entry."],"exampleFix":"# before\nfoo = { optional = true }\n# after\nfoo = { version = \"1.0\", optional = true }","handlingStrategy":"validation","validationCode":"const SOURCES: [&str; 4] = [\"git\", \"path\", \"version\", \"workspace\"];\nfor (k, item) in deps {\n    if let Some(t) = item.as_table_like() {\n        if !SOURCES.iter().any(|s| t.contains_key(s)) {\n            eprintln!(\"dependency {k} has no source key\");\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Every dependency table must include at least one of version/path/git/workspace.","Validate manifests with `toml` + a schema check before parsing.","Prefer `cargo add <name>` which always emits a well-formed entry."],"tags":["manifest","dependencies","validation"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}