Skip to content

Exclude all non-members from workspace #13600

Open
@konstin

Description

@konstin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-workspacesArea: workspacesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions