Skip to content

Commit

Permalink
fix: better error message for using the script as a dep
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Jan 13, 2025
1 parent d8be32e commit a4ca61d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/cargo/sources/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ impl<'gctx> PathSource<'gctx> {
}

fn read_package(&self) -> CargoResult<Package> {
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)
Expand Down
5 changes: 1 addition & 4 deletions tests/testsuite/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a4ca61d

Please sign in to comment.