Skip to content

Commit c8e9bcc

Browse files
committed
Explicit error for --path with/Cargo.toml
1 parent 0731d17 commit c8e9bcc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cargo/ops/cargo_add/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ fn resolve_dependency(
378378
};
379379
selected
380380
} else if let Some(raw_path) = &arg.path {
381-
let path = paths::normalize_path(&std::env::current_dir()?.join(raw_path));
381+
let relative_path = Path::new(raw_path);
382+
if relative_path.ends_with("Cargo.toml") {
383+
anyhow::bail!("local crate paths must be specified without /Cargo.toml: {}", relative_path.parent().unwrap().display());
384+
}
385+
let path = paths::normalize_path(&std::env::current_dir()?.join(relative_path));
382386
let mut src = PathSource::new(path);
383387
src.base = arg.base.clone();
384388

0 commit comments

Comments
 (0)