diff --git a/src/cargo/core/source_id.rs b/src/cargo/core/source_id.rs index df958bf133d..dade72b5a4b 100644 --- a/src/cargo/core/source_id.rs +++ b/src/cargo/core/source_id.rs @@ -208,7 +208,7 @@ impl SourceId { /// /// `path`: an absolute path. pub fn for_manifest_path(manifest_path: &Path) -> CargoResult { - if crate::util::toml::is_embedded(manifest_path) { + if crate::util::toml::is_embedded(manifest_path) && manifest_path.is_file() { Self::for_path(manifest_path) } else { Self::for_path(manifest_path.parent().unwrap()) @@ -404,7 +404,7 @@ impl SourceId { .url .to_file_path() .expect("path sources cannot be remote"); - if crate::util::toml::is_embedded(&path) { + if crate::util::toml::is_embedded(&path) && path.is_file() { anyhow::bail!("single file packages cannot be used as dependencies") } Ok(Box::new(PathSource::new(&path, self, gctx))) diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 9efa5c73fd4..2791cb88f89 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -1083,20 +1083,31 @@ pub fn root_manifest(manifest_path: Option<&Path>, gctx: &GlobalContext) -> Carg // In general, we try to avoid normalizing paths in Cargo, // but in this particular case we need it to fix #3586. let path = paths::normalize_path(&path); - if !path.ends_with("Cargo.toml") && !crate::util::toml::is_embedded(&path) { - anyhow::bail!( - "the manifest-path must be a path to a Cargo.toml file: `{}`", - path.display() - ) - } if !path.exists() { anyhow::bail!("manifest path `{}` does not exist", manifest_path.display()) - } - if path.is_dir() { + } else if path.is_dir() { + let child_path = path.join("Cargo.toml"); + let suggested_path = if child_path.exists() { + format!("\nhelp: {} exists", child_path.display()) + } else { + "".to_string() + }; anyhow::bail!( - "manifest path `{}` is a directory but expected a file", + "manifest path `{}` is a directory but expected a file{suggested_path}", manifest_path.display() ) + } else if !path.ends_with("Cargo.toml") && !crate::util::toml::is_embedded(&path) { + if gctx.cli_unstable().script { + anyhow::bail!( + "the manifest-path must be a path to a Cargo.toml or script file: `{}`", + path.display() + ) + } else { + anyhow::bail!( + "the manifest-path must be a path to a Cargo.toml file: `{}`", + path.display() + ) + } } if crate::util::toml::is_embedded(&path) && !gctx.cli_unstable().script { anyhow::bail!("embedded manifest `{}` requires `-Zscript`", path.display()) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 27f8de9df8a..46313e9e771 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -49,10 +49,7 @@ use self::targets::to_targets; /// See also `bin/cargo/commands/run.rs`s `is_manifest_command` pub fn is_embedded(path: &Path) -> bool { let ext = path.extension(); - (ext == Some(OsStr::new("rs")) || - // Provide better errors by not considering directories to be embedded manifests - ext.is_none()) - && path.is_file() + ext == Some(OsStr::new("rs")) || ext.is_none() } /// Loads a `Cargo.toml` from a file on disk. diff --git a/tests/testsuite/bad_manifest_path.rs b/tests/testsuite/bad_manifest_path.rs index c497e303f85..cd97224b870 100644 --- a/tests/testsuite/bad_manifest_path.rs +++ b/tests/testsuite/bad_manifest_path.rs @@ -4,7 +4,7 @@ use crate::prelude::*; use cargo_test_support::{basic_bin_manifest, main_file, project, str}; #[track_caller] -fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) { +fn assert_bad_manifest_path(command: &str, manifest_path_argument: &str, stderr: impl IntoData) { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) @@ -15,310 +15,694 @@ fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) { .arg(manifest_path_argument) .cwd(p.root().parent().unwrap()) .with_status(101) - .with_stderr_data( - "[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/[..]`\n", - ) - .run(); -} - -#[track_caller] -fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) { - let p = project().build(); - let expected_path = manifest_path_argument - .split('/') - .collect::>() - .join("[..]"); - - p.cargo(command) - .arg("--manifest-path") - .arg(manifest_path_argument) - .cwd(p.root().parent().unwrap()) - .with_status(101) - .with_stderr_data(format!( - "[ERROR] manifest path `{}` does not exist\n", - expected_path - )) + .with_stderr_data(stderr) .run(); } #[cargo_test] fn bench_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("bench", "foo"); + assert_bad_manifest_path( + "bench", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn bench_dir_plus_file() { - assert_not_a_cargo_toml("bench", "foo/bar"); + assert_bad_manifest_path( + "bench", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn bench_dir_plus_path() { - assert_not_a_cargo_toml("bench", "foo/bar/baz"); + assert_bad_manifest_path( + "bench", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn bench_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("bench", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "bench", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn build_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("check", "foo"); + assert_bad_manifest_path( + "check", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn build_dir_plus_file() { - assert_not_a_cargo_toml("bench", "foo/bar"); + assert_bad_manifest_path( + "bench", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn build_dir_plus_path() { - assert_not_a_cargo_toml("bench", "foo/bar/baz"); + assert_bad_manifest_path( + "bench", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn build_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("check", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "check", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn clean_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("clean", "foo"); + assert_bad_manifest_path( + "clean", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn clean_dir_plus_file() { - assert_not_a_cargo_toml("clean", "foo/bar"); + assert_bad_manifest_path( + "clean", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn clean_dir_plus_path() { - assert_not_a_cargo_toml("clean", "foo/bar/baz"); + assert_bad_manifest_path( + "clean", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn clean_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("clean", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "clean", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn doc_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("doc", "foo"); + assert_bad_manifest_path( + "doc", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn doc_dir_plus_file() { - assert_not_a_cargo_toml("doc", "foo/bar"); + assert_bad_manifest_path( + "doc", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn doc_dir_plus_path() { - assert_not_a_cargo_toml("doc", "foo/bar/baz"); + assert_bad_manifest_path( + "doc", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn doc_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("doc", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "doc", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn fetch_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("fetch", "foo"); + assert_bad_manifest_path( + "fetch", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn fetch_dir_plus_file() { - assert_not_a_cargo_toml("fetch", "foo/bar"); + assert_bad_manifest_path( + "fetch", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn fetch_dir_plus_path() { - assert_not_a_cargo_toml("fetch", "foo/bar/baz"); + assert_bad_manifest_path( + "fetch", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn fetch_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("fetch", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "fetch", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn generate_lockfile_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("generate-lockfile", "foo"); + assert_bad_manifest_path( + "generate-lockfile", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn generate_lockfile_dir_plus_file() { - assert_not_a_cargo_toml("generate-lockfile", "foo/bar"); + assert_bad_manifest_path( + "generate-lockfile", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn generate_lockfile_dir_plus_path() { - assert_not_a_cargo_toml("generate-lockfile", "foo/bar/baz"); + assert_bad_manifest_path( + "generate-lockfile", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn generate_lockfile_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("generate-lockfile", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "generate-lockfile", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn package_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("package", "foo"); + assert_bad_manifest_path( + "package", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn package_dir_plus_file() { - assert_not_a_cargo_toml("package", "foo/bar"); + assert_bad_manifest_path( + "package", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn package_dir_plus_path() { - assert_not_a_cargo_toml("package", "foo/bar/baz"); + assert_bad_manifest_path( + "package", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn package_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("package", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "package", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn pkgid_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("pkgid", "foo"); + assert_bad_manifest_path( + "pkgid", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn pkgid_dir_plus_file() { - assert_not_a_cargo_toml("pkgid", "foo/bar"); + assert_bad_manifest_path( + "pkgid", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn pkgid_dir_plus_path() { - assert_not_a_cargo_toml("pkgid", "foo/bar/baz"); + assert_bad_manifest_path( + "pkgid", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn pkgid_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("pkgid", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "pkgid", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn publish_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("publish", "foo"); + assert_bad_manifest_path( + "publish", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn publish_dir_plus_file() { - assert_not_a_cargo_toml("publish", "foo/bar"); + assert_bad_manifest_path( + "publish", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn publish_dir_plus_path() { - assert_not_a_cargo_toml("publish", "foo/bar/baz"); + assert_bad_manifest_path( + "publish", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn publish_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("publish", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "publish", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn read_manifest_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("read-manifest", "foo"); + assert_bad_manifest_path( + "read-manifest", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn read_manifest_dir_plus_file() { - assert_not_a_cargo_toml("read-manifest", "foo/bar"); + assert_bad_manifest_path( + "read-manifest", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn read_manifest_dir_plus_path() { - assert_not_a_cargo_toml("read-manifest", "foo/bar/baz"); + assert_bad_manifest_path( + "read-manifest", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn read_manifest_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("read-manifest", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "read-manifest", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn run_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("run", "foo"); + assert_bad_manifest_path( + "run", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn run_dir_plus_file() { - assert_not_a_cargo_toml("run", "foo/bar"); + assert_bad_manifest_path( + "run", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn run_dir_plus_path() { - assert_not_a_cargo_toml("run", "foo/bar/baz"); + assert_bad_manifest_path( + "run", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn run_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("run", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "run", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn rustc_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("rustc", "foo"); + assert_bad_manifest_path( + "rustc", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn rustc_dir_plus_file() { - assert_not_a_cargo_toml("rustc", "foo/bar"); + assert_bad_manifest_path( + "rustc", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn rustc_dir_plus_path() { - assert_not_a_cargo_toml("rustc", "foo/bar/baz"); + assert_bad_manifest_path( + "rustc", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn rustc_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("rustc", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "rustc", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn test_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("test", "foo"); + assert_bad_manifest_path( + "test", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn test_dir_plus_file() { - assert_not_a_cargo_toml("test", "foo/bar"); + assert_bad_manifest_path( + "test", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn test_dir_plus_path() { - assert_not_a_cargo_toml("test", "foo/bar/baz"); + assert_bad_manifest_path( + "test", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn test_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("test", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "test", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] fn update_dir_containing_cargo_toml() { - assert_not_a_cargo_toml("update", "foo"); + assert_bad_manifest_path( + "update", + "foo", + str![[r#" +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists + +"#]], + ); } #[cargo_test] fn update_dir_plus_file() { - assert_not_a_cargo_toml("update", "foo/bar"); + assert_bad_manifest_path( + "update", + "foo/bar", + str![[r#" +[ERROR] manifest path `foo/bar` does not exist + +"#]], + ); } #[cargo_test] fn update_dir_plus_path() { - assert_not_a_cargo_toml("update", "foo/bar/baz"); + assert_bad_manifest_path( + "update", + "foo/bar/baz", + str![[r#" +[ERROR] manifest path `foo/bar/baz` does not exist + +"#]], + ); } #[cargo_test] fn update_dir_to_nonexistent_cargo_toml() { - assert_cargo_toml_doesnt_exist("update", "foo/bar/baz/Cargo.toml"); + assert_bad_manifest_path( + "update", + "foo/bar/baz/Cargo.toml", + str![[r#" +[ERROR] manifest path `foo/bar/baz/Cargo.toml` does not exist + +"#]], + ); } #[cargo_test] @@ -335,7 +719,7 @@ fn verify_project_dir_containing_cargo_toml() { str![[r#" [ { - "invalid": "the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo`" + "invalid": "manifest path `foo` is a directory but expected a file\n[HELP] [ROOT]/foo/Cargo.toml exists" } ] "#]] @@ -359,7 +743,7 @@ fn verify_project_dir_plus_file() { str![[r#" [ { - "invalid": "the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/bar`" + "invalid": "manifest path `foo/bar` does not exist" } ] "#]] @@ -383,7 +767,7 @@ fn verify_project_dir_plus_path() { str![[r#" [ { - "invalid": "the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/bar/baz`" + "invalid": "manifest path `foo/bar/baz` does not exist" } ] "#]] diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 872886e7c52..d42455ff388 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -2394,7 +2394,8 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_parent_relative() { .cwd(p.root().parent().unwrap()) .with_status(101) .with_stderr_data(str![[r#" -[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo` +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists "#]]) .run(); @@ -2412,7 +2413,8 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute() { .cwd(p.root().parent().unwrap()) .with_status(101) .with_stderr_data(str![[r#" -[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo` +[ERROR] manifest path `[ROOT]/foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists "#]]) .run(); diff --git a/tests/testsuite/read_manifest.rs b/tests/testsuite/read_manifest.rs index 496088874e4..5e14674c901 100644 --- a/tests/testsuite/read_manifest.rs +++ b/tests/testsuite/read_manifest.rs @@ -75,7 +75,8 @@ fn cargo_read_manifest_path_to_cargo_toml_parent_relative() { .cwd(p.root().parent().unwrap()) .with_status(101) .with_stderr_data(str![[r#" -[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo` +[ERROR] manifest path `foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists "#]]) .run(); @@ -93,7 +94,8 @@ fn cargo_read_manifest_path_to_cargo_toml_parent_absolute() { .cwd(p.root().parent().unwrap()) .with_status(101) .with_stderr_data(str![[r#" -[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo` +[ERROR] manifest path `[ROOT]/foo` is a directory but expected a file +[HELP] [ROOT]/foo/Cargo.toml exists "#]]) .run(); diff --git a/tests/testsuite/script/cargo.rs b/tests/testsuite/script/cargo.rs index dec2b721216..d9c3f8b8a46 100644 --- a/tests/testsuite/script/cargo.rs +++ b/tests/testsuite/script/cargo.rs @@ -1567,7 +1567,7 @@ fn cmd_check_with_missing_script_rs() { .with_status(101) .with_stdout_data("") .with_stderr_data(str![[r#" -[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/script.rs` +[ERROR] manifest path `script.rs` does not exist "#]]) .run(); @@ -1582,7 +1582,7 @@ fn cmd_check_with_missing_script() { .with_status(101) .with_stdout_data("") .with_stderr_data(str![[r#" -[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/script` +[ERROR] manifest path `script` does not exist "#]]) .run();