rust-lang/cargo · error · anyhow::Error
dependency ( ) specified without providing a local path…
Error message
dependency ({}) specified without providing a local path, Git repository, or version What it means
Thrown during dependency resolution in query_dependency() when a workspace dependency (declared in [workspace.dependencies]) has no version, path, or git source specified, and querying it returns MaybeWorkspace::Workspace recursively — meaning the workspace definition itself is incomplete and has no concrete source to resolve.
Solutions
- Add a version, path, or git source to the [workspace.dependencies] entry in the workspace root Cargo.toml
- If the dependency should be a path dependency within the workspace, add `path = "../member"` to the workspace dependency entry
- Remove the broken workspace dependency reference from the member crate if it is no longer needed
Example fix
# before (workspace root Cargo.toml)
[workspace.dependencies]
my-crate = {}
# error: dependency (my-crate) specified without providing a
# local path, Git repository, or version
# after
[workspace.dependencies]
my-crate = "1.0" Defensive patterns
Strategy: validation
Validate before calling
// Validate workspace dependency has a source before use
fn validate_workspace_dep(ws_toml: &toml::Value, key: &str) -> Result<(), String> {
let dep = ws_toml["workspace"]["dependencies"]
.get(key)
.ok_or_else(|| format!("workspace dependency `{key}` not found"))?;
let has_source = dep.get("version").is_some()
|| dep.get("path").is_some()
|| dep.get("git").is_some()
|| dep.get("workspace").is_some();
if !has_source {
return Err(format!("workspace dependency `{key}` has no version, path, or git source"));
}
Ok(())
} Prevention
- Always provide version, path, or git for every [workspace.dependencies] entry
- Run cargo check after adding workspace dependencies to catch incomplete entries early
- Use CI validation to ensure all workspace dependency entries have concrete sources
When it happens
Trigger: A package depends on a workspace dependency (via `dep.workspace = true`) where the corresponding [workspace.dependencies] entry lacks version, path, git, or workspace source information. The double MaybeWorkspace::Workspace match at line 667 indicates the workspace entry points back to itself.
Common situations: Incomplete [workspace.dependencies] table where an entry was added as a placeholder without a source. Refactoring that removed the version/path from a workspace dependency but left references in member crates.
Related errors
- cannot override workspace dependency with
- cannot add ` ` as a dependency to itself
- cannot specify a git URL
- cannot specify a path
- unrecognized feature
AI-assisted analysis of rust-lang/cargo@98a09e7e7d (2026-08-11).
Data as JSON: /api/errors/41fbaace61305e78.
Report an issue: GitHub.
Appendix: source
Thrown at src/ops/cargo_add/mod.rs:671
gctx: &GlobalContext,
dependency: &mut Dependency,
) -> CargoResult<crate::workspace::Dependency> {
let query = dependency.query(gctx)?;
let query = match query {
MaybeWorkspace::Workspace(_workspace) => {
let dep = find_workspace_dep(
dependency.toml_key(),
ws,
ws.root_manifest(),
ws.unstable_features(),
)?;
if let Some(features) = dep.features.clone() {
*dependency = dependency.clone().set_inherited_features(features);
}
let query = dep.query(gctx)?;
match query {
MaybeWorkspace::Workspace(_) => {
anyhow::bail!(
"dependency ({}) specified without \
providing a local path, Git repository, or version",
dependency.toml_key()
);
}
MaybeWorkspace::Other(query) => query,
}
}
MaybeWorkspace::Other(query) => query,
};
Ok(query)
}
fn fuzzy_lookup(
dependency: &mut Dependency,
lookup: impl Fn(&str) -> CargoResult<Option<Dependency>>,
gctx: &GlobalContext,
) -> CargoResult<Option<Dependency>> {View on GitHub (pinned to 98a09e7e7d)