-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Nested workspaces #5042
Comments
A lightweight way to help here might be to just ignore nested virtual manifests. If we want to be strict, we could do this only if the outer manifest includes all the workspace members in the inner manifest. This might admit some errors where there is an ignored Cargo.toml somewhere in a tree of workspaces, but I don't think that is much of a hazard, especially if the outer manifest explicitly includes the inner members. One question is forwards compatibility, if one day we want to allow true nested workspaces, then I'm not sure how well that co-exists with this simpler proposal. I think technically it would be OK, but it might be hard to understand for users. cc @rust-lang/cargo - thoughts? If this sounds OK, then I'd quite like to implement so that we can make Rustfmt and maybe RLS use workspaces (and even Cargo!). |
This is already supported with the help of
|
I don't think the exclude trick quite works for the case I have in mind. I have:
Where bar/Cargo.toml is
and ./Cargo.toml is
When I
And I don't think I can fix that subject to the constraint that baz may be a Git submodule and should build in its own context too. |
Hm, that looks interesting! So basically we have Why does |
It's not a dependency of anything in the The concrete example here is tools in the Rust repo when Rust is |
I discussed with @alexcrichton on irc, it turns out that this would actually be a breaking change: in my example above, you can't currently build the outer workspace but you can build An alternative would be to only ignore So, I think the better solution is the breaking change, since I doubt anyone actually uses nested workspaces right now since they are broken when building at the top. However, since it is breaking, it probably needs an RFC, or at least a bit more advertising and discussion than a quick 'bug fix'. |
@nrc this was initially motivated by the rust-lang/rust repo, right? I think that Cargo may have actually progressed far enough at this point to deal with git dependencies gracefully that it may work (previously we had to avoid git dependencies). I wonder if that'd be an option to avoid vendoring rustfmt's source code? |
@nrc I'm interested to understand what experience you had that motivated this. I understand the mechanics of what you're proposing, and I'd find it helpful to understand what situation the mechanics are targeting. |
@alexcrichton how would we run rustfmt tests if we used it as a dep? @wycats the motivation is where you want to pull in a workspace project as a Git submodule and a workspace member of another project. The specific example here is pulling Rustfmt into the Rust repo. |
@nrc bah excellent point! |
I came here to mention this exact use case. At work I've got one project which would like to use a crate from another project. I was initially making project B a git submodule of project A and then using a
|
@nrc What if, in your example, change [workspace]
members = ["foo", "bar"] So, that one of the workspace members is a workspace itself. This is now actually nested workspaces, not intersecting like before. So, every member of the inner workspace should be considered as a member of the outer one.
This invariant should still hold, just some crates (like Currently this produces this error:
|
Any updates on this? I like the solution proposed by @kuviman since it would reduce redundancy in nested virtual manifests. Something I haven't seen discussed yet is how nested workspaces should behave wrt implicit members in non-virtual manifests. How would those be handled? |
Bumping for visibility. I would love to see this resolved. Nested workspaces seems like a common use case. |
I created a separate branch for the inner repository named "as_submodule". The inner repositories' "as_submodule" branch is identical to master branch, minus the root Cargo.toml workspace. So when somebody wants to include the project as a submodule they do I don't like doing it this way, so the README points to this issue for people who judge :) |
This is my first "tru" involvement in the Rust development ecosystem (I'm not really sure how to contribute to Rust and am not very knowledgeable on lexers, parsers and whatnot). I would love to have this resolved. I am currently working on an operating system that is structured like so:
I'd like to divide this up into workspaces: the main kernel tree as the "top-level" workspace, then nested workspaces under that (i.e. "drivers" is a workspace, "acpi" is another, ...). Currently (unless this issue has been resolved) I am unable to make this layout without creating separate repositories, which makes it harder to manage the tree as a hole as I am the only maintainer right now. |
See rust-lang/cargo#5042 for details.
I got it by this issue too. I have a crate that have multiples binaries, and multiple libraries, so I'm using a workspace. I had to vendor another library that itself uses a workspace. In order to do so, I had to modify it to move its workspace from its |
This is how I work around rust-lang/cargo#5042 to get path dependencies into vendored Rust dependencies. The generated BUILD files are built with google#524, because otherwise they don't work. This fixes google#361.
Would it be possible to introduce nested workspaces "light", where they may be used under the condition that a workspace which contains a workspace must not contain a package? This would allow for most common use cases of one workspace combining multiple projects (which are workspaces with multiple crates) into one project. Though it works to open the parent folder in CLion and attaching all children to it, it would be a neat QOL change, allowing deduplication of profile configurations and allowing building / testing / etc. in one command. |
Ran into this today. Our use case is vendoring mdbook plugins as git submodules. Cargo.toml [workspace]
resolver = "2"
members = ["mdbook-external-links", "mdbook-linkcheck", "mdbook-toc"] book.toml [preprocessor.external-links]
command = "cargo run -p mdbook-external-links --locked --release --"
I'm unsure if there's a better way that retains the ability to include plugins as submodules rather than needing them installed on the system. |
Also just ran into this ... was trying to add a fork of wgpu as a submodule of a project as I need to modify the naga subcrate that was recently moved to it. Would love to see support added for this! Think it will become increasingly common as more stuff moves to monorepos / workspaces. |
I'm also having problems with this, I have a Rust/C++ project that links to a cdylib made in Rust, which is a git submodule in |
chore: remove workspace manifest see rust-lang/cargo#5042
Is any RFC in progress? |
There has been exploration in the past. If @Muscraft's notes aren't captured here, it would be good to do so for anyone else who wants to take on the design work. No one is actively working on this and, usually when they do, there will be posts in the relevant issues pointing people to things like a Pre-RFC on Internals or an RFC. In other words, if there isn't already a message about progress, there unlikely is to be any.
FYI "bumps" are counter productive. While they send someone a notification, it is a low value notification that is more likely to annoy people than to help spur things to move forward. They make full inboxes even more full, full threads even more full, etc. What would be helpful instead is to document use cases and how they affect designs (if yours isn't already captured). A lot of talk here is vaguely about git submodule cases without an explanation for why a package from a workspace in a submodule needs to be pulled into the users workspace. This also sounds more like wanting to have packages belong to multiple workspaces which is different than nested workspaces (strict parent/child relationships) and designs for each can go in very different directions. In talking about use cases, it would help to consider what are needs/nice-to-haves, and don't-cares (with "why") for things like:
|
I agree, will refrain from such behavior.. ᓚᘏᗢ |
I stumbled over this issue and try to give you an overview over my use-case. Please be aware that I'm a beginner in terms of rust and might not have understood yet the ideal ways to set something up. I'm having a workspace setup with multiple libs and binaries and also a fyrox game, intended to run in the browser. The fyrox game is unfortunaly a workspace on its own, because it contains automatically subprojects for the engine, etc. With nested worspaces I would hope to refere to the nested projects by sub_workspace::project and the projects them selves would not need to know that there are different projects in other sub-workspaces with the same name. |
Allow multiple layers of workspaces, not just one. This would be useful for tools in the Rust repo, and I think more generally.
The text was updated successfully, but these errors were encountered: