diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index e3a6d64921..10b2946b29 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -1001,7 +1001,27 @@ pub fn build( // ones recipes actually rewrite. let source_is_submodule = source_real.join(".git").exists(); + // Cargo path dependencies that ESCAPE the source tree cannot be + // staged: they are resolved relative to the manifest, so moving the + // manifest breaks them. redbear-greeter depends on + // `../redbear-login-protocol/source`, which under staging resolved + // to /target/redbear-login-protocol/source and failed: + // failed to read .../target/redbear-login-protocol/source/Cargo.toml + // No such file or directory (os error 2) + // Rewriting the manifests would edit dependency paths behind the + // recipe's back; leaving these in tree is the honest option. They + // are Rust recipes that build via cargo and do not sed their source, + // so the mutation risk staging protects against does not apply. + let escapes_source_tree = fs::read_to_string(source_real.join("Cargo.toml")) + .map(|manifest| { + manifest + .lines() + .any(|l| l.contains("path") && l.contains("\"..") ) + }) + .unwrap_or(false); + let source_is_tracked = !source_is_submodule + && !escapes_source_tree && std::env::var_os("REDBEAR_IN_TREE_BUILD").is_none() && Command::new("git") .arg("ls-files")