Skip to content

Installing with the --bin flag removes unrelated orphaned bins #17372

Description

@CarbonSmasher

Problem

When installing with the --bin flag, unrelated binaries that are no longer in the manifest, but used to be in the same crate, will be removed

Steps

Say your crate has two binaries, bin_a, and bin_b

  1. Install bin_a with cargo install --path my_crate --bin bin_a
  2. Remove bin_a from the manifest. This can happen often if you are switching branches.
  3. Install bin_b with cargo install --path my_crate --bin bin_b

Unexpectedly to me, bin_a will be removed from your .cargo/bin directory.

This behavior makes sense if you are installing the crate holistically, say with --bins, since the crate changed holistically (a binary was removed). However, I would argue that with the --bin flag, a user expects to only touch the specific binary they are referencing.

Possible Solution(s)

No response

Notes

No response

Version

`rustc --version --verbose`:

rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3

`cargo --version --verbose`

cargo 1.92.0 (344c4567c 2025-10-21)
release: 1.92.0
commit-hash: 344c4567c634a25837e3c3476aac08af84cf9203
commit-date: 2025-10-21
host: x86_64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.15.0-DEV (sys:0.4.83+curl-8.15.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Arch Linux Rolling Release [64-bit]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugCommand-installS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions