Skip to content

Unintuitive behavior when both features and package are specified #8368

@kornelski

Description

@kornelski

If I have a workspace:

Cargo.toml
foo/Cargo.toml

and run in the root of the workspace:

cargo build -p foo --features=bar

Cargo fails with an error #7742:

error: --features is not allowed in the root of a virtual workspace

while

cd foo
cargo build --features=bar

is accepted. It's surprising that specifying -p is not equivalent to building in that package's directory.

I expected that when -p points to a specific package, Cargo wouldn't try to use non-existent features from the root manifest (#4942), but instead look for the features in that package's own manifest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions