nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

respect previously defined feature flags when updating #251

Closed rursprung closed 4 months ago

rursprung commented 7 months ago

if an application has been installed using feature flags (e.g. cargo install probe-rs --features cli) cargo install-update currently does not respect this and will instead install the new version without any feature flags.

based on a brief look it seems that ~/.cargo/.crates.toml does not contain the feature flags used, but ~/.cargo/.crates2.json does. it furthermore also contains all_features and no_default_features which are also relevant. since .crates2.json seems to contain everything .crates.toml does and then some it might be enough to just read the information from there. the new file has been introduced with https://github.com/rust-lang/cargo/issues/6667, it will not be present for older cargo installations (so depending on how much backwards compatibility with old cargo versions you want to keep you might have to keep the code for parsing the old file if the new one is not present)

it'd be great if this information could be considered when running the installation of the new version.

nabijaczleweli commented 7 months ago

Dupe of #249 #211 #180; use cargo install-update-config -f feat -f feat pkg, per manual.

SteveLauC commented 4 months ago

Hi, looks like this wasn't implemented because cargo didn't store it in the past, but for now, we have this information in file ~/.cargo/.crates2.json, any change we can implement this feature and enable it by default?

nabijaczleweli commented 4 months ago

hm, indeed

$ jq < ~/.cargo/.crates2.json
{
  "installs": {
    "pixelmatch 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)": {
      "version_req": null,
      "bins": [
        "pixelmatch"
      ],
      "features": [
        "build-binary"
      ],
      "all_features": false,
      "no_default_features": false,
      "profile": "release",
      "target": "x86_64-unknown-linux-gnu",
      "rustc": "rustc 1.54.0 (a178d0322 2021-07-26)\nbinary: rustc\ncommit-hash: a178d0322ce20e33eac124758e837cbd80a6f633\ncommit-date: 2021-07-26\nhost: x86_64-unknown-linux-gnu\nrelease: 1.54.0\nLLVM version: 12.0.1\n"
    },

let's see

nabijaczleweli commented 4 months ago

Can you try the current master branch (at least e82363cd5172efed30ec67b365c71030c7597f90)?

SteveLauC commented 4 months ago

I don't have an outdated binary to test for now, cc folks who are also interested in this feature: @ncihnegn @simonsan @ModProg @dotdash @tranzystorekk

BTW, thanks for the quick response and implementation!

nabijaczleweli commented 2 months ago

Released in v14.0.0