Skip to content

Commit 183eeff

Browse files
committed
fix: better error message for using the script as a dep
1 parent 1514c7e commit 183eeff

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cargo/sources/path.rs

+3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ impl<'gctx> PathSource<'gctx> {
124124
}
125125

126126
fn read_package(&self) -> CargoResult<Package> {
127+
if crate::util::toml::is_embedded(&self.path) {
128+
anyhow::bail!("The embedded script cannot be used as a dependency");
129+
}
127130
let path = self.path.join("Cargo.toml");
128131
let pkg = ops::read_package(&path, self.source_id, self.gctx)?;
129132
Ok(pkg)

tests/testsuite/script.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1402,10 +1402,7 @@ Caused by:
14021402
Unable to update [ROOT]/foo/script.rs
14031403
14041404
Caused by:
1405-
failed to read `[ROOT]/foo/script.rs/Cargo.toml`
1406-
1407-
Caused by:
1408-
Not a directory (os error 20)
1405+
The embedded script cannot be used as a dependency
14091406
14101407
"#]])
14111408
.run();

0 commit comments

Comments
 (0)