rust-lang / rust-lang/cargo

Binary project output within one workspace depends on build order

Open
#8,941 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-layout A-rebuild-detection C-bug S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Create a workspace with two projects whose Cargo.toml files define a binary named runner, then reproduce the behavior with cargo run -p project_b --bin runner. Trace Cargo's workspace binary selection and output handling; done means the requested project is selected reliably or Cargo reports the duplicate or conflicting configuration explicitly.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.