Exclude [workspace] from cunew-generated toml #180
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I used
cunew
to generate a new project and hit a couple issues but this one is the one that makes most sense to fix.I have a bit of an odd setup here. My user-side repo at
$HOME/Repos/scratchpad
and my Cargo workspace root is at$HOME/Repos/scratchpad/car
. In my workspace, I just add all the crates in my project as members so I can build everything easily.When I ran cunew, I ran it from the templates dir in my local copper repo, so this:
When I built my code from the workspace root or the new copper project, I got this error
mike@fedora:copper $ cargo b error: multiple workspace roots found in the same workspace: /home/mike/Repos/scratchpad/car/copper/car /home/mike/Repos/scratchpad/car
This is the reason this doesn't work: https://doc.rust-lang.org/cargo/reference/manifest.html#the-workspace-field
Omitting this element from the toml should fix it. I think that if users want this as the workspace root, they could add that in. I think this would relate to #142
Another issue I hit is that the
local
copper repo option only works if the generated project is in the copper repo. I hit a permission issue trying to refer to my copper repo from my new project, but I figure that might just be an intentional decision from cargo on how it manages directories/permissions anyways. Based on a skim of https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-path-dependencies, it doesn't seem like paths outside of repos are supported and I don't really blame them tbh.Some conditional handling around new workspaces vs new projects in an existing workspace would make sense, but I think that having
[workspace]
in the toml makes the assumption that we're generating a new root workspace which isn't always true. Tell me if my understanding is wrong though.