From d6cf5f60dd8908e769d8cba64a6c3d5897d73e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20C=C3=B4rte-Real?= Date: Fri, 2 Oct 2020 04:29:02 +0100 Subject: [PATCH] Ignore paths that don't exist for dependencies If a given path is not a valid dependency, just ignore it. This allows falling back to git or the repository automatically while retaining the ability to have the code locally if you need to develop a dependency in tandem with the crate code. Fixes #8747 --- src/cargo/util/toml/mod.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 4bb1d7f4d2b..1941b6d4e7c 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1642,9 +1642,23 @@ impl DetailedTomlDependency { } } + // Ignore paths that don't exist so as to fallback onto some other + // source in that circumstance. This allows specifying dependencies + // from crates.io or git as well as a local path for development and + // having everything just work. + let path = if let Some(path) = &self.path { + if Path::new(&path).join("Cargo.toml").exists() { + self.path.as_ref() + } else { + None + } + } else { + None + }; + let new_source_id = match ( self.git.as_ref(), - self.path.as_ref(), + path, self.registry.as_ref(), self.registry_index.as_ref(), ) {