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

respect previously defined feature flags when updating #251

Closed
rursprung opened this issue Feb 28, 2024 · 5 comments
Closed

respect previously defined feature flags when updating #251

rursprung opened this issue Feb 28, 2024 · 5 comments

Comments

@rursprung
Copy link

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 rust-lang/cargo#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
Copy link
Owner

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

@SteveLauC
Copy link

SteveLauC commented May 25, 2024

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
Copy link
Owner

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
Copy link
Owner

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

@SteveLauC
Copy link

SteveLauC commented May 25, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants