Skip to content

Suggested cargo fix command fails for workspace packages not in default-members #15982

@Alexendoo

Description

@Alexendoo

Problem

With the following root Cargo.toml:

[workspace]
members = ["a"]
default-members = []
resolver = "3"

If the workspace member a emits a fixable diagnostic, e.g.

% cargo check -p a
    Checking a v0.1.0 (/home/gh-Alexendoo/temp/a)
warning: unnecessary parentheses around assigned value
 --> a/src/main.rs:2:13
  |
2 |     let _ = (1);
  |             ^ ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
2 -     let _ = (1);
2 +     let _ = 1;
  |

warning: `a` (bin "a") generated 1 warning (run `cargo fix --bin "a"` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s

Running the suggested command results in an error:

% cargo fix --bin "a"
error: manifest path `/home/gh-Alexendoo/temp` contains no package: The manifest is virtual, and the workspace has no members.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.90.0 (840b83a10 2025-07-30)
release: 1.90.0
commit-hash: 840b83a10fb0e039a83f4d70ad032892c287570a
commit-date: 2025-07-30
host: aarch64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.14.1-DEV (sys:0.4.82+curl-8.14.1 vendored ssl:OpenSSL/3.5.0)
ssl: OpenSSL 3.5.0 8 Apr 2025
os: Ubuntu 24.4.0 (noble) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugE-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions