fix: better error message for using the script as a dep

Signed-off-by: Rustin170506 <techregister@pm.me>
This commit is contained in:
Rustin170506 2025-01-13 22:53:38 +08:00
parent 1514c7e630
commit 91da8dba0d
2 changed files with 4 additions and 4 deletions

View File

@ -393,6 +393,9 @@ impl SourceId {
.url
.to_file_path()
.expect("path sources cannot be remote");
if crate::util::toml::is_embedded(&path) {
anyhow::bail!("Single file packages cannot be used as dependencies")
}
Ok(Box::new(PathSource::new(&path, self, gctx)))
}
SourceKind::Registry | SourceKind::SparseRegistry => Ok(Box::new(

View File

@ -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)
Single file packages cannot be used as dependencies
"#]])
.run();