Skip to content

Commit d8583f4

Browse files
committed
fix(cli): Improve error on manifest dir
1 parent 85023c4 commit d8583f4

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/cargo/util/command_prelude.rs

+6
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,12 @@ pub fn root_manifest(manifest_path: Option<&Path>, config: &Config) -> CargoResu
790790
if !path.exists() {
791791
anyhow::bail!("manifest path `{}` does not exist", manifest_path.display())
792792
}
793+
if path.is_dir() {
794+
anyhow::bail!(
795+
"manifest path `{}` is a directory but expected a file",
796+
manifest_path.display()
797+
)
798+
}
793799
if crate::util::toml::is_embedded(&path) && !config.cli_unstable().script {
794800
anyhow::bail!("embedded manifest `{}` requires `-Zscript`", path.display())
795801
}

tests/testsuite/script.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,7 @@ fn script_like_dir() {
448448
.with_status(101)
449449
.with_stderr(
450450
"\
451-
[ERROR] failed to read `[ROOT]/foo/script.rs`
452-
453-
Caused by:
454-
Is a directory (os error 21)
451+
error: manifest path `script.rs` is a directory but expected a file
455452
",
456453
)
457454
.run();

0 commit comments

Comments
 (0)