Skip to content

Commit

Permalink
fix(new): Add to workspace relative to manifest, not current-dir
Browse files Browse the repository at this point in the history
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 rust-lang#14501
  • Loading branch information
epage authored and dingxiangfei2009 committed Sep 17, 2024
1 parent 32dcd87 commit c1b5cad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ fn mk(gctx: &GlobalContext, opts: &MkOptions<'_>) -> CargoResult<()> {
}
}

let manifest_path = path.join("Cargo.toml");
let manifest_path = paths::normalize_path(&path.join("Cargo.toml"));
if let Ok(root_manifest_path) = find_root_manifest_for_wd(&manifest_path) {
let root_manifest = paths::read(&root_manifest_path)?;
// Sometimes the root manifest is not a valid manifest, so we only try to parse it if it is.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[workspace]
members = ["../out-of-workspace"]

[package]
name = "foo"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c1b5cad

Please sign in to comment.