Skip to content

Commit 378458a

Browse files
committed
fix(new): Add to workspace relative to manifest, not current-dir
We were correctly doing this for cases like `cargo new foo` or `cargo new deeper/than/this/directory/foo` but not `cargo new ../foo`. This came up when discussing #14501
1 parent d9ae1fd commit 378458a

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ fn mk(gctx: &GlobalContext, opts: &MkOptions<'_>) -> CargoResult<()> {
802802
}
803803
}
804804

805-
let manifest_path = path.join("Cargo.toml");
805+
let manifest_path = paths::normalize_path(&path.join("Cargo.toml"));
806806
if let Ok(root_manifest_path) = find_root_manifest_for_wd(&manifest_path) {
807807
let root_manifest = paths::read(&root_manifest_path)?;
808808
// Sometimes the root manifest is not a valid manifest, so we only try to parse it if it is.

tests/testsuite/cargo_new/ignore_current_dir_workspace/out/workspace/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[workspace]
2-
members = ["../out-of-workspace"]
32

43
[package]
54
name = "foo"

tests/testsuite/cargo_new/ignore_current_dir_workspace/stderr.term.svg

Lines changed: 3 additions & 12 deletions
Loading

0 commit comments

Comments
 (0)