Skip to content

cargo new with workspace: exclude/include #13198

New issue

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

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

Already on GitHub? # to your account

Closed
dumindu opened this issue Dec 23, 2023 · 2 comments
Closed

cargo new with workspace: exclude/include #13198

dumindu opened this issue Dec 23, 2023 · 2 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@dumindu
Copy link

dumindu commented Dec 23, 2023

Problem

Currently when we run cargo new command inside a workspace, it gives following warnings,

warning: compiling this new package may not work due to invalid workspace configuration

current package believes it's in a workspace when it's not:
current:   /path/to/workspace/new_crate/Cargo.toml
workspace: /path/to/workspace/new_crate/Cargo.toml

this may be fixable by adding `new_crate ` to the `workspace.members` array of the manifest located at: /path/to/workspace/Cargo.toml
Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.

Additionally, while running cargo run new_crate it gives following errors(but no issue with cargo run --bin new_crate)

warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
   Compiling api v0.1.0 (/path/to/workspace/new_crate)
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `target/debug/api api`

Proposed Solution

  1. We can add following commands
  • cargo new -we and cargo new -wi
  • cargo new --workspace exclude and cargo new --workspace include
  1. The scope of the resolver is bit unclear for me. If we add cargo workspace command, we can add more subcommands I think.

Notes

No response

@dumindu dumindu added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Dec 23, 2023
@dumindu dumindu changed the title cargo new with workspace: exclude/include and resolver: 1/2 cargo new with workspace: exclude/include Dec 23, 2023
@epage
Copy link
Contributor

epage commented Dec 23, 2023

This was always meant to be an intermediate state which was addressed in #12779 which will be released in 1.75 next week. We went the opinionated route of always adding to the workspace.

@dumindu
Copy link
Author

dumindu commented Dec 23, 2023

Duplicate: #6378

@dumindu dumindu closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants