Skip to content
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

Exclude all non-members from workspace #13600

Open
konstin opened this issue Mar 18, 2024 · 1 comment
Open

Exclude all non-members from workspace #13600

konstin opened this issue Mar 18, 2024 · 1 comment
Labels
A-workspaces Area: workspaces C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@konstin
Copy link
Contributor

konstin commented Mar 18, 2024

Problem

In uv, we have a number of crates in a crates/ directory, and this root Cargo.toml to go with it:

[workspace]
members = ["crates/*"]
exclude = [
  "scripts",
  # Needs nightly
  "crates/uv-trampoline",
]
resolver = "2"

Since we're a python build tool, we sometimes have to clone repositories that contain a Cargo.toml on their own, e.g.

cargo run pip install deptry --no-binary deptry --cache-dir foo

or, for a minimal example:

mkdir bar && cd bar && git clone https://github.com/fpgmaas/deptry && cd deptry && cargo check

The build of deptry fails:

error: current package believes it's in a workspace when it's not:
current:   /home/konsti/projects/uv/bar/deptry/Cargo.toml
workspace: /home/konsti/projects/uv/Cargo.toml

this may be fixable by adding `bar/deptry` to the `workspace.members` array of the manifest located at: /home/konsti/projects/uv/Cargo.toml
Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.

I can add foo or bar to workspace.exclude, but i would like to exclude all directories that aren't crates. I tried *, **, **/*, ./*, ./** and ./**/* to no avail. "./" works but removes all members from the workspace.

Proposed Solution

A switch to exclude all non-member packages from the workspace.

Notes

No response

@konstin konstin added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Mar 18, 2024
@epage epage added the A-workspaces Area: workspaces label Mar 18, 2024
@epage
Copy link
Contributor

epage commented Mar 18, 2024

#11405 covers some cases for improving workspace membership inclusion.

I also wonder if rust-lang/rfcs#3279 could be used here to allow the cloned repo to not search higher up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-workspaces Area: workspaces C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants