-
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
Workspaces: All crates below the root folder must be members of the workspace #3159
Comments
This is indeed correct! Unfortunately I'm not sure there's a lot we can do about this... We can perhaps add cc @rust-lang/tools |
@alexcrichton I think that the explicit opt-out should be in the "root" crate, instead of the Cargo.toml of a dependency. Perhaps have a |
@4e554c4c hm yeah that sounds reasonable, some form of configuration in the workspace root indicating "please don't include this area" |
To clarify: This problem even occurs when there is no dependency on An opt-out in the root crate wouldn't really solve this problem, since Alternatively, the proposed |
@phil-opp isn't the workspace root here though aware of the filesystem layout? Enough to know to reject the directory with |
Unfortunately this can wreak havoc with lock files. One of the crucial properties of a workspace is that all members agree on the set of crates in a workspace. If disagreement were allowed then this could cause |
I don't know how it's implemented. I thought that the root crate only scans its
All members agree that The problem is that we can't compile
This error message is strange. The |
Ah so the problem here is that sub2 does indeed think it's in a workspace. The logic for finding your workspace is to either look at The change I'm thinking of here is that the workspace itself says "this path is excluded" so if the "walk up" logic walks along that path then it just aborts and says there's no workspace. |
I've got an idea for a motification to workspaces which I believe fixes this. If you're interested in this issue and that doesn't work for you though please let me know! |
I believe with the |
The workspace documentation says the following:
(emphasis mine)
This implies that all crates below the workspace root must be part of the workspace, even if there are no dependencies on them.
For example, imagine the following workspace layout.
The root
Cargo.toml
defines a workpace with membersub1
:Now we can build the root project and
sub1
without problems. But when we try to buildsub2
, the following error occurs:So
sub2
blindly assumes that it's part of the workspace, even though it's not part ofworkspace.members
.Real World Example: Imagine working with git worktree. This command allows you to temporary check out a branch in a subfolder. For example, you might want to do a quick bugfix on master while working on a feature branch (let's say that you want to introduce cargo workspaces in your project).
So you check out the master branch in a
bugfix
subfolder. The youcd
into it and try to build it. But it fails with the same error as above because your crate now thinks that it's part of the root workspace.The text was updated successfully, but these errors were encountered: