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

workspace.exclude disregarded for crate in subdir of workspace.member #14155

Closed
Enselic opened this issue Jun 26, 2024 · 1 comment
Closed

workspace.exclude disregarded for crate in subdir of workspace.member #14155

Enselic opened this issue Jun 26, 2024 · 1 comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@Enselic
Copy link
Member

Enselic commented Jun 26, 2024

Problem

It seems as if cargo does not always notice that a package is part of workspace.exclude . This happens when the excluded package is in a subdir of a package which is in workspace.members, and e.g. cargo check is invoked directly on the excluded package.

Step-by-step

  1. Cherry-pick this commit to the cargo repo which adds the following test:
#[cargo_test]
fn excluded_subcrate_of_workspace_member() {
    let p = project()
        .file(
            "Cargo.toml",
            r#"
                [workspace]
                members = [
                    "member",
                ]
                exclude = [
                    "member/excluded",
                ]
            "#,
        )
        .file("member/src/main.rs", "fn main() {}")
        .file("member/Cargo.toml", &basic_manifest("member", "0.1.0"))
        .file("member/excluded/src/main.rs", "fn main() {}")
        .file(
            "member/excluded/Cargo.toml",
            &basic_manifest("excluded", "0.1.0"),
        );
    let p = p.build();

    p.cargo("check").cwd("member/excluded").run();
}
  1. cargo test excluded_subcrate_of_workspace_member

Expected

Test passes

Actual

The test fails with

--- stderr
error: current package believes it's in a workspace when it's not:
current:   /home/martin/src/cargo/target/tmp/cit/t0/foo/member/excluded/Cargo.toml
workspace: /home/martin/src/cargo/target/tmp/cit/t0/foo/Cargo.toml

this may be fixable by adding `member/excluded` to the `workspace.members` array of the manifest located at: /home/martin/src/cargo/target/tmp/cit/t0/foo/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.

which is strange, since the package is already in the workspace.exclude array. But it does not seem to be noticed by cargo.

Version

git master branch of cargo
@Enselic Enselic added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jun 26, 2024
@ehuss
Copy link
Contributor

ehuss commented Jun 26, 2024

Thanks for the report! I believe this is a duplicate of #6745, so closing in favor of that.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants