-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Perhaps cargo new should have a [workspace] tag? #12998
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
Comments
Workspaces aren't immediately covered because they are for bigger, more complex cases. As for Something I've considered is overloading |
At first glance, I like the idea of having workspace discovery turned off by default. But this is a behavioral change that will affect existing projects. So, if this is done, without breaking the build of all people using workspaces out there, this would demand a new cargo edition field version, right? On the other hand, are there any people that are creating a complex project and creating blindly, say, 7 subprojects using In the book, people will be made aware early on that there is a "big thing called workspace, that for now you won't need, but check chapter X". There is no need to make complex explanations at that point: only that the '[workspace]' thing makes your project standalone. One thing that people must be cautions always is the see-saw effect (people having to change configurations at either side manually to make things work, which may make people to change settings and breaking the other people repos on pull) , and the "it work at my machine" effect (some hidden setting at the user home or some parent directory changing how cargo build stuff). package.workspace settings has all the smells of "it work at my machine" settings. While a new line when creating a new project is something that will be committed into the repo and can be removed (and committed) as part of the solution. |
To be clear, I meant that by default
I want to re-emphasize: if we unconditionally put So that just leaves conditionally adding it. The question is if we'll cause more annoyance with |
The cargo team discussed this and decided to close. Not all projects need (or want) a workspace, and there could be unwanted interactions with intentionally adding packages inside a workspace. It sounds like some of the confusion here stems from diagnostics that did not explain what was happening or why. I think #13904 is the main issue for that. Also, we did have some orthogonal desire to be able to have opt-in control the adding to a workspace with a CLI flag, but I think that is a separate concern (tracked in #8365). |
Problem
As I've worked through the cargo book, and started working at another chapters, I got a surprise by the lack of awareness of the concept of cargo workspaces. This is discussed in the book project issue rust-lang/book#3779 .
Basically I inadvertedly added one "rust project" inside another. I didn't know that the cargo.toml files are not "isolated" by themselves, and keep looking for workspace tags in the parent directories. This is never explained in the 1st chapter of the cargo book, and got me into a puzzling experience , discussed in the forum https://users.rust-lang.org/t/what-is-the-correlation-between-two-cargo-toml-in-the-file-hierarchy/101933/11
Proposed Solution
The proposed solution is that cargo new should create empty workspaces by default, making beginner projects to be standalone projects.
https://users.rust-lang.org/t/what-is-the-correlation-between-two-cargo-toml-in-the-file-hierarchy/101933/8
And the book project should make a very simple and quick explanation of workspaces directly at the hello cargo chapter. As discussed in the book issue mentioned before.
Notes
No response
The text was updated successfully, but these errors were encountered: