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

Flag to not add a crate to a workspace when calling cargo new #13871

Open
Makogan opened this issue May 6, 2024 · 1 comment
Open

Flag to not add a crate to a workspace when calling cargo new #13871

Makogan opened this issue May 6, 2024 · 1 comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-init Command-new S-triage Status: This issue is waiting on initial triage.

Comments

@Makogan
Copy link

Makogan commented May 6, 2024

Problem

There should be a flag to instruct cargo new not to edit a workspace's root Cargo.toml by appending the crrate to its workspace members.
This PR partially addresses the issue but not entirely. One should be able to call cargo new without it editing the root's Cago.toml even if it has a workspace declaration.

This the situation I am running into. I use spirv-builder at runtime to compile rust source code into spirv for hot reloading of shaders. I thus often run cargo new to initialize the shader crate. However, I am forced to delete it from the workspace members each time, because this crate won't be compiled under the regular cargo workflow. Having a flag to disable the feature would be useful.

Proposed Solution

Add a flag that prevents cargo new from editing a workspace's Cargo.toml

Notes

No response

@Makogan Makogan 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 May 6, 2024
@epage
Copy link
Contributor

epage commented May 6, 2024

This the situation I am running into. I use spirv-builder at runtime to compile rust source code into spirv for hot reloading of shaders. I thus often run cargo new to initialize the shader crate. However, I am forced to delete it from the workspace members each time, because this crate won't be compiled under the regular cargo workflow. Having a flag to disable the feature would be useful.

If I'm understanding this, it sounds like cargo new is being invoked programmatically with expectations on the results? If so, then that is something intentionally not supported for cargo new.

The assumptions for the not providing a flag were

  • The command is meant to be used interactively
  • Hand edits on top of what was generated are expected
  • By creating a package in a workspace, the intent of wanting it to be a member is very strong.

For myself, I am hesitant to add many flags to customize the behavior of cargo new. Cargo is designed to be opinionated and cargo new in particular is not intended for heavy customization (deferring that to #5151). The closest I could see doing is #8365 since making it a workspace would mean we shouldn't add it as a workspace member.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-init Command-new S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants