Skip to content

Commit

Permalink
fix(cli): Improve error on manifest dir
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jun 21, 2023
1 parent 85023c4 commit d8583f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,12 @@ pub fn root_manifest(manifest_path: Option<&Path>, config: &Config) -> CargoResu
if !path.exists() {
anyhow::bail!("manifest path `{}` does not exist", manifest_path.display())
}
if path.is_dir() {
anyhow::bail!(
"manifest path `{}` is a directory but expected a file",
manifest_path.display()
)
}
if crate::util::toml::is_embedded(&path) && !config.cli_unstable().script {
anyhow::bail!("embedded manifest `{}` requires `-Zscript`", path.display())
}
Expand Down
5 changes: 1 addition & 4 deletions tests/testsuite/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,7 @@ fn script_like_dir() {
.with_status(101)
.with_stderr(
"\
[ERROR] failed to read `[ROOT]/foo/script.rs`
Caused by:
Is a directory (os error 21)
error: manifest path `script.rs` is a directory but expected a file
",
)
.run();
Expand Down

0 comments on commit d8583f4

Please sign in to comment.