Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstalling binaries from a crate while specifying fewer features does not remove already installed binaries corresponding to no longer active features #15079

Open
auno opened this issue Jan 17, 2025 · 0 comments
Labels
C-bug Category: bug Command-install S-triage Status: This issue is waiting on initial triage.

Comments

@auno
Copy link

auno commented Jan 17, 2025

Problem

If you first install the binaries of a crate using cargo install, then issue another cargo install specifying fewer features in a way that should result in fewer binaries, those binaries which corresponds to no longer active features are not removed. I'm not sure if this is the intended behavior or not (I could not find anything clear about it), but it was at least not the behavior I expected.

Steps

  1. Install a crate with multiple binaries tied to different features and examine result.

    $ cargo install --root cargo-home convert2json
        Updating crates.io index
      Installing convert2json v1.1.4
    ...
       Compiling convert2json v1.1.4
        Finished `release` profile [optimized] target(s) in 14.51s
      Installing cargo-home/bin/cq
      Installing cargo-home/bin/csv2json
      Installing cargo-home/bin/ini2json
      Installing cargo-home/bin/iq
      Installing cargo-home/bin/rq
      Installing cargo-home/bin/rsv2json
      Installing cargo-home/bin/toml2json
      Installing cargo-home/bin/tq
      Installing cargo-home/bin/xml2json
      Installing cargo-home/bin/xq
      Installing cargo-home/bin/yaml2json
      Installing cargo-home/bin/yq
       Installed package `convert2json v1.1.4` (executables `cq`, `csv2json`, `ini2json`, `iq`, `rq`, `rsv2json`, `toml2json`, `tq`, `xml2json`, `xq`, `yaml2json`, `yq`)
    $ ls cargo-home/bin/
    cq  csv2json  ini2json  iq  rq  rsv2json  toml2json  tq  xml2json  xq  yaml2json  yq
    
  2. Reinstall the same crate with features disabled and examine the result to see that the same binaries are still installed.

    $ cargo install --root cargo-home --no-default-features --features xml convert2json
        Updating crates.io index
      Installing convert2json v1.1.4
    ...
       Compiling convert2json v1.1.4
        Finished `release` profile [optimized] target(s) in 8.18s
       Replacing cargo-home/bin/xml2json
       Replacing cargo-home/bin/xq
        Replaced package `convert2json v1.1.4` with `convert2json v1.1.4` (executables `cq`, `csv2json`, `ini2json`, `iq`, `rq`, `rsv2json`, `toml2json`, `tq`, `xml2json`, `xq`, `yaml2json`, `yq`)
    $ ls cargo-home/bin/
    cq  csv2json  ini2json  iq  rq  rsv2json  toml2json  tq  xml2json  xq  yaml2json  yq
    
  3. Manually remove installed binaries, install again with features disabled, and examine the result to see that only a subset of binaries are installed. This is what I would have expected already at step 2.

    $ rm -r cargo-home/
    $ cargo install --root cargo-home --no-default-features --features xml convert2json
        Updating crates.io index
      Installing convert2json v1.1.4
    ...
        Finished `release` profile [optimized] target(s) in 8.21s
      Installing cargo-home/bin/xml2json
      Installing cargo-home/bin/xq
       Installed package `convert2json v1.1.4` (executables `xml2json`, `xq`)
    $ ls cargo-home/bin/
    xml2json  xq
    

Possible Solution(s)

The straight forward solution, I assume, would be to list installed binaries at the start of the process, then do the compilation and installation, and finally remove any previously installed binaries that where not replaced by the newly compiled crate.

Version

cargo 1.84.0 (66221abde 2024-11-19)
release: 1.84.0
commit-hash: 66221abdeca2002d318fde6efff516aab091df0e
commit-date: 2024-11-19
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Linux Mint 21.2.0 (victoria) [64-bit]
@auno auno added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jan 17, 2025
@auno auno changed the title Reinstalling binaries from a crate while specifying fewer features does remove already installed binaries corresponding to no longer active features Reinstalling binaries from a crate while specifying fewer features does not remove already installed binaries corresponding to no longer active features Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-install S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants