Skip to content

Binary project output within one workspace depends on build order #8941

@mineichen

Description

@mineichen

Multiple projects within a workspace overwrite each others output, if their executable have the same name.

Imagine the following Cargo.toml snippet to be part of two projects (referred to as project_aand project_b):

[[bin]]
name = "runner"
path = "src/main.rs"

When compiling the workspace after a change in project_a, the following command runs the executable from project_a:

cargo run -p project_b --bin runner

Problems

  1. I expected the -p flag to be considered or to rise a warning that it's being ignored in conjunction with --bin
  2. Cargo workspaces allow two projects to target the same binary name, but currently names must be unique within the workspace

Possible Solution(s)

  1. Deprecate -p and --bin to be used in conjunction
  2. Fail workspace build if two projects use the same binary-name

Notes
Output of cargo version:

cargo 1.48.0 (65cbdd2dc 2020-10-14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: target output directory layout, naming, and organizationA-rebuild-detectionArea: rebuild detection and fingerprintingC-bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions