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
Signed-off-by: Rustin170506 <techregister@pm.me>
  • Loading branch information
Rustin170506 committed Feb 4, 2025
1 parent 1514c7e commit 91da8db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/cargo/core/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
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)
Single file packages cannot be used as dependencies
"#]])
.run();
Expand Down

0 comments on commit 91da8db

Please sign in to comment.