Skip to content

Commit dd0815e

Browse files
committed
Allow cargo add --path with/Cargo.toml
1 parent 0731d17 commit dd0815e

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 mut relative_path = Path::new(raw_path);
382+
if relative_path.ends_with("Cargo.toml") {
383+
relative_path = relative_path.parent().unwrap();
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)