Skip to content

Commit a2f9032

Browse files
committed
Detect incorrectly named cargo.toml for install --path
1 parent d9daaf7 commit a2f9032

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/cargo/ops/cargo_install.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,19 @@ fn install_one(
212212
src.path().display()
213213
);
214214
} else {
215-
bail!(
216-
"`{}` does not contain a Cargo.toml file. \
215+
if src.path().join("cargo.toml").exists() {
216+
bail!(
217+
"`{}` does not contain a Cargo.toml file, but found cargo.toml please try to rename it to Cargo.toml. \
217218
--path must point to a directory containing a Cargo.toml file.",
218-
src.path().display()
219-
)
219+
src.path().display()
220+
)
221+
} else {
222+
bail!(
223+
"`{}` does not contain a Cargo.toml file. \
224+
--path must point to a directory containing a Cargo.toml file.",
225+
src.path().display()
226+
)
227+
}
220228
}
221229
}
222230
select_pkg(

tests/testsuite/install.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ fn missing() {
245245
}
246246

247247
#[cargo_test]
248+
#[cfg(not(target_os = "macos"))]
248249
fn pkg_missing_cargo_toml() {
249250
let p = project()
250251
.file(
251-
"Cargo1.toml",
252+
"cargo.toml",
252253
r#"
253254
[package]
254255
name = "foo"
@@ -259,13 +260,12 @@ fn pkg_missing_cargo_toml() {
259260
.file("src/main.rs", "fn main() {}")
260261
.build();
261262

262-
cargo_process("install")
263+
cargo_process("install --path .")
263264
.arg(p.root())
264265
.with_status(101)
265266
.with_stderr(
266267
"\
267-
[UPDATING] [..] index
268-
[ERROR] could not find `[..]` in registry `[..]` with version `*`
268+
[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.
269269
",
270270
)
271271
.run();

0 commit comments

Comments
 (0)