Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect incorrectly named cargo.toml #9607

Merged
merged 4 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Detect incorrectly named cargo.toml for install --path
  • Loading branch information
Rustin170506 committed Jun 22, 2021
commit a2f903275a5506b638312a522b63f5757333547b
16 changes: 12 additions & 4 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,19 @@ fn install_one(
src.path().display()
);
} else {
bail!(
"`{}` does not contain a Cargo.toml file. \
if src.path().join("cargo.toml").exists() {
bail!(
"`{}` does not contain a Cargo.toml file, but found cargo.toml please try to rename it to Cargo.toml. \
--path must point to a directory containing a Cargo.toml file.",
src.path().display()
)
src.path().display()
)
} else {
bail!(
"`{}` does not contain a Cargo.toml file. \
--path must point to a directory containing a Cargo.toml file.",
src.path().display()
)
}
}
}
select_pkg(
Expand Down
8 changes: 4 additions & 4 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,11 @@ fn missing() {
}

#[cargo_test]
#[cfg(not(target_os = "macos"))]
fn pkg_missing_cargo_toml() {
let p = project()
.file(
"Cargo1.toml",
"cargo.toml",
r#"
[package]
name = "foo"
Expand All @@ -259,13 +260,12 @@ fn pkg_missing_cargo_toml() {
.file("src/main.rs", "fn main() {}")
.build();

cargo_process("install")
cargo_process("install --path .")
.arg(p.root())
.with_status(101)
.with_stderr(
"\
[UPDATING] [..] index
[ERROR] could not find `[..]` in registry `[..]` with version `*`
[ERROR] `[CWD]` does not contain a Cargo.toml but found cargo.toml please try to rename it to Cargo.toml. --path must point to a directory containing a Cargo.toml file.
",
)
.run();
Expand Down