Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo is inconsistent in working with workspace members #14168

Closed
rosti-il opened this issue Jun 29, 2024 · 1 comment
Closed

Cargo is inconsistent in working with workspace members #14168

rosti-il opened this issue Jun 29, 2024 · 1 comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@rosti-il
Copy link

Problem

Running a command like cargo new main never adds the [workspace] section into the Cargo.toml it just created. This is already reported as a feature request in #8365, but there are more issues with that.

In case you cd into that directory and run cargo new baz there is a message that "baz" was added as a member into the workspace of its parent. But actually nothing is added and there is still no [workspace] section in the first Cargo.toml. But if you add an empty [workspace] section into the first Cargo.toml manually, before adding a child package then the child package will be added into the members array of the [workspace] section as well. If Cargo can't add a new workspace member without the [workspace] section existing then an error must be printed. Otherwise it should create the [workspace] section and add the new member into it. Now it just lies and it looks like a bug.

Steps

This is from Bash of Git for Windows:

$ cargo new --vcs none main && cd main
    Creating binary (application) `main` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

$ cat Cargo.toml
[package]
name = "main"
version = "0.1.0"
edition = "2021"

[dependencies]

$ cargo new baz
    Creating binary (application) `baz` package
      Adding `baz` as member of workspace at `D:\develop\2\main`
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

$ cat Cargo.toml
[package]
name = "main"
version = "0.1.0"
edition = "2021"

[dependencies]

$ rm -rf baz

$ echo "[workspace]" >> Cargo.toml

$ cat Cargo.toml
[package]
name = "main"
version = "0.1.0"
edition = "2021"

[dependencies]
[workspace]

$ cargo new baz
    Creating binary (application) `baz` package
      Adding `baz` as member of workspace at `D:\develop\2\main`
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

$ cat Cargo.toml
[package]
name = "main"
version = "0.1.0"
edition = "2021"

[dependencies]
[workspace]
members = ["baz"]

Possible Solution(s)

No response

Notes

No response

Version

$ cargo version --verbose
cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.19045 (Windows 10 Pro) [64-bit]
@rosti-il rosti-il added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jun 29, 2024
@ehuss
Copy link
Contributor

ehuss commented Jun 29, 2024

Thanks for the report! This has already been fixed in #13987 and will be available in the next release (1.80).

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants