Skip to content

cargo install --git finds binaries in crates that are not part of the root workspace #9011

Closed
@lopopolo

Description

@lopopolo

Problem

When running cargo install with a git repository, cargo finds bin targets in all crates in the repository, even if they are not part of the root workspace.

artichoke/artichoke declares a Cargo.toml workspace like:

[workspace]
members = [
  "artichoke-backend",
  "artichoke-core",
  "scolapasta-hex",
  "scolapasta-string-escape",
  "spinoso-array",
  "spinoso-env",
  "spinoso-exception",
  "spinoso-math",
  "spinoso-random",
  "spinoso-securerandom",
  "spinoso-symbol",
  "spinoso-time",
]

The workspace is not virtual. There is a root crate that has two bin targets. These bin targets are the only binaries built by this root workspace.

Both artichoke-fuzz and spec-runner are crates at the top-level of the repository, but are not part of the root workspace. These crates declare they are the sole member of a subworkspace with:

# `spec-runner` is a regression testing tool
# Remove it from the main artichoke workspace.
[workspace]
members = ["."]

I would expect to be able to run cargo install --git https://github.com/artichoke/artichoke --branch trunk without specifying a target crate, since the root workspace only has one crate with bin targets.

Steps

$ cargo install --git https://github.com/artichoke/artichoke --branch trunk
    Updating git repository `https://github.com/artichoke/artichoke`
error: multiple packages with binaries found: artichoke, artichoke-fuzz, spec-runner

Possible Solution(s)

Notes

Output of cargo version:

$ cargo -Vv
cargo 1.48.0 (65cbdd2dc 2020-10-14)
release: 1.48.0
commit-hash: 65cbdd2dc0b7e877577474b98b7d071308d0bb6f
commit-date: 2020-10-14

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions