Workspace `exclude` doesn't work if nested under a `member` path
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Problem
It doesn't appear as though the workspace.exclude key works for paths that are nested under a path included in workspace.members
Steps
- Create a nested package structure:
/tmp % cargo new outer
Created binary (application) `outer` package
/tmp % cd outer
/tmp/outer % cargo new middle
Created binary (application) `middle` package
/tmp/outer % cd middle
/tmp/outer/middle % cargo new inner
Created binary (application) `inner` package
- Add a
workspace.memberskey to the outermost level, and observe that the workspace build succeeds:
/tmp/outer/middle % cd /tmp/outer
/tmp/outer % echo "[workspace]\n members = [\".\", \"middle\"]" >> Cargo.toml
/tmp/outer % cargo build --all
Compiling middle v0.1.0 (/tmp/outer/middle)
Compiling outer v0.1.0 (/tmp/outer)
Finished dev [unoptimized + debuginfo] target(s) in 0.34s
- Now go to the inner package and observe that the build fails:
/tmp/outer % cd /tmp/outer/middle/inner
/tmp/outer/middle/inner % cargo build
error: current package believes it's in a workspace when it's not:
current: /tmp/outer/middle/inner/Cargo.toml
workspace: /tmp/outer/Cargo.toml
this may be fixable by adding `middle/inner` to the `workspace.members` array of the manifest located at: /tmp/outer/Cargo.toml
- Fair enough; let's explicitly exclude this package instead, and try again:
/tmp/outer/middle/inner % cd /tmp/outer
/tmp/outer % echo "exclude = [\"middle/inner\"]" >> Cargo.toml
/tmp/outer % cd /tmp/outer/middle/inner
/tmp/outer/middle/inner % cargo build
error: current package believes it's in a workspace when it's not:
current: /tmp/outer/middle/inner/Cargo.toml
workspace: /tmp/outer/Cargo.toml
this may be fixable by adding `middle/inner` to the `workspace.members` array of the manifest located at: /tmp/outer/Cargo.toml
It still wants to be in the workspace! We're stuck.
Possible Solution(s)
If there's overlap between paths in members and exclude, I would expect the more-specific path to win. In this case, the excluded path "middle/inner" is more specific than the member paths "." or "middle", so the exclusion should win. This is probably not so simple if the paths contain globs, though.
Notes
Output of cargo version:
% cargo version
cargo 1.31.0 (339d9f9c8 2018-11-16)
Thanks for your looking into this 🦀
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the nested packages using the outer, middle, and inner Cargo.toml files, then run cargo build from the inner package with workspace.members and workspace.exclude configured as shown. Trace Cargo's workspace member and exclusion resolution; done means the excluded middle/inner package builds independently without the workspace error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100