Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,10 @@ pub fn root_manifest(manifest_path: Option<&Path>, gctx: &GlobalContext) -> Carg
// 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")
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())
Expand Down
10 changes: 6 additions & 4 deletions tests/testsuite/bad_manifest_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ 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\n")
.with_stderr_data(
"[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/[..]`\n",
)
.run();
}

Expand Down Expand Up @@ -333,7 +335,7 @@ fn verify_project_dir_containing_cargo_toml() {
str![[r#"
[
{
"invalid": "the manifest-path must be a path to a Cargo.toml file"
"invalid": "the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo`"
}
]
"#]]
Expand All @@ -357,7 +359,7 @@ fn verify_project_dir_plus_file() {
str![[r#"
[
{
"invalid": "the manifest-path must be a path to a Cargo.toml file"
"invalid": "the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/bar`"
}
]
"#]]
Expand All @@ -381,7 +383,7 @@ fn verify_project_dir_plus_path() {
str![[r#"
[
{
"invalid": "the manifest-path must be a path to a Cargo.toml file"
"invalid": "the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/bar/baz`"
}
]
"#]]
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2397,7 +2397,7 @@ 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
[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo`

"#]])
.run();
Expand All @@ -2415,7 +2415,7 @@ 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
[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo`

"#]])
.run();
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/read_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ 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
[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo`

"#]])
.run();
Expand All @@ -93,7 +93,7 @@ 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
[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo`

"#]])
.run();
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,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
[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/script.rs`

"#]])
.run();
Expand All @@ -1373,7 +1373,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
[ERROR] the manifest-path must be a path to a Cargo.toml file: `[ROOT]/foo/script`

"#]])
.run();
Expand Down
Loading