{"id":"41fbaace61305e78","repo":"rust-lang/cargo","slug":"dependency-specified-without-providing-a-loca","errorCode":null,"errorMessage":"dependency ({}) specified without providing a local path, Git repository, or version","messagePattern":"dependency \\((.+?)\\) specified without providing a local path, Git repository, or version","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_add/mod.rs","lineNumber":654,"sourceCode":"    gctx: &GlobalContext,\n    dependency: &mut Dependency,\n) -> CargoResult<crate::workspace::Dependency> {\n    let query = dependency.query(gctx)?;\n    let query = match query {\n        MaybeWorkspace::Workspace(_workspace) => {\n            let dep = find_workspace_dep(\n                dependency.toml_key(),\n                ws,\n                ws.root_manifest(),\n                ws.unstable_features(),\n            )?;\n            if let Some(features) = dep.features.clone() {\n                *dependency = dependency.clone().set_inherited_features(features);\n            }\n            let query = dep.query(gctx)?;\n            match query {\n                MaybeWorkspace::Workspace(_) => {\n                    anyhow::bail!(\n                        \"dependency ({}) specified without \\\n                        providing a local path, Git repository, or version\",\n                        dependency.toml_key()\n                    );\n                }\n                MaybeWorkspace::Other(query) => query,\n            }\n        }\n        MaybeWorkspace::Other(query) => query,\n    };\n    Ok(query)\n}\n\nfn fuzzy_lookup(\n    dependency: &mut Dependency,\n    lookup: impl Fn(&str) -> CargoResult<Option<Dependency>>,\n    gctx: &GlobalContext,\n) -> CargoResult<Option<Dependency>> {","sourceCodeStart":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_add/mod.rs#L636-L672","documentation":"During registry lookup, `query_dependency` recurses into workspace inheritance: if a dependency resolves to `MaybeWorkspace::Workspace`, cargo looks it up in `[workspace.dependencies]`. Should that *also* come back as `Workspace` (i.e. the workspace dep has no concrete source itself), the resolver bails at mod.rs:654 because there is no local path, git, or version to anchor the dependency.","triggerScenarios":"A `[workspace.dependencies]` entry declared as `{ workspace = true }` (transitive/forwarding) with no version/path/git, and a member references it. The double-Workspace resolution has no concrete source to query.","commonSituations":"Mistakenly nesting workspace dependencies, or refactoring a workspace dep into a stub that never gets a real source assigned.","solutions":["Give the `[workspace.dependencies.<key>]` entry a concrete `version`, `path`, or `git`.","If the member needs its own source, declare it directly in the member manifest instead of inheriting an empty workspace entry.","Audit the workspace root `Cargo.toml` for entries that only set `workspace = true` and supply them with a real source."],"exampleFix":"# before (root Cargo.toml)\n[workspace.dependencies]\nserde = { workspace = true }\n\n# after\n[workspace.dependencies]\nserde = \"1\"","handlingStrategy":"validation","validationCode":"// Validate workspace.dependencies entries have a concrete source before adding members.\nfn ws_deps_are_concrete(root_manifest: &toml_edit::DocumentMut) -> Result<(), Vec<String>> {\n    let mut bad = Vec::new();\n    if let Some(t) = root_manifest.get(\"workspace\").and_then(|i| i.as_table()) {\n        if let Some(deps) = t.get(\"dependencies\").and_then(|i| i.as_table_like()) {\n            for (k, v) in deps.iter() {\n                let only_ws = v.as_table_like()\n                    .map(|tt| tt.contains_key(\"workspace\") && tt.len() == 1)\n                    .unwrap_or(false);\n                if only_ws { bad.push(k.to_string()); }\n            }\n        }\n    }\n    if bad.is_empty() { Ok(()) } else { Err(bad) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always give `[workspace.dependencies]` entries a `version`, `path`, or `git`.","Add a CI check that scans the root manifest for `workspace = true` stubs.","Avoid forwarding workspace deps through other workspace deps."],"tags":["cargo-add","workspace","inheritance","missing-source"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}