diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 7765906977f..a38661ff9ad 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -124,6 +124,9 @@ impl<'gctx> PathSource<'gctx> { } fn read_package(&self) -> CargoResult { + if crate::util::toml::is_embedded(&self.path) { + anyhow::bail!("The embedded script cannot be used as a dependency"); + } let path = self.path.join("Cargo.toml"); let pkg = ops::read_package(&path, self.source_id, self.gctx)?; Ok(pkg) diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index 53569caa9a6..742315877d5 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -1402,10 +1402,7 @@ Caused by: Unable to update [ROOT]/foo/script.rs Caused by: - failed to read `[ROOT]/foo/script.rs/Cargo.toml` - -Caused by: - Not a directory (os error 20) + The embedded script cannot be used as a dependency "#]]) .run();