nabijaczleweli / cargo-update

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

Question: Does `cargo install-update -a` respect previous --locked preference? #152

Closed nth10sd closed 3 years ago

nth10sd commented 3 years ago

Deno recommends installing via cargo install deno --locked.

If a subsequent run of cargo install-update -a to pull in a new version of Deno is executed, will cargo-update respect the --locked preference? (Hopefully it does)

nabijaczleweli commented 3 years ago

It doesn't, because no such preference exists.

The way to persist installation options for cargo-update is cargo-install-update-config(1) – it doesn't have that option at present, since it appears to be relatively fresh.

nabijaczleweli commented 3 years ago

Can you try with the current master branch (at least 1ecbf08e2368a1b6b937630630e1d67f7a7100b2)? cargo install-update-config --enforce-lock deno should get you there.

nth10sd commented 3 years ago

Will cargo install-update-config --enforce-lock deno work well in tandem with cargo install-update -a? (I'm sorry I only really use the latter)

nabijaczleweli commented 3 years ago

Yes, if you run the former once, all subsequent runs of the latter will run cargo install [...] --locked deno on upgrades.

nth10sd commented 3 years ago

Excellent, seems to work:

$ cargo install-update-config --enforce-lock deno
Enforce lock      true
Default features  true
$ cargo install-update -a
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package      Installed  Latest   Needs update
bat          v0.18.0    v0.18.0  No
bottom       v0.5.7     v0.5.7   No
cargo-bloat  v0.10.0    v0.10.0  No
cw           v0.7.0     v0.7.0   No
deno         v1.8.3     v1.8.3   No
/snip

Can we also have a separate column in this listing above denoting Locked as Yes for Deno, No for the rest?

nth10sd commented 3 years ago

The use case would be if we enforce the lock, uninstall it, then subsequently reinstall Deno via just cargo install deno without --locked. This scenario would make it unclear whether the lock is enforced or not.

nabijaczleweli commented 3 years ago

Glad to see it works. I can provide no guarantees so as to what environment the crate was compiled in (or, indeed, any on-disk state of any binaries) and I'm not sure how you suppose that possible.

nabijaczleweli commented 3 years ago

Released in v6.0.0.

nth10sd commented 3 years ago

Understood.

Can we also have a separate column in this listing above

However, wouldn't this be possible for the overview shown in cargo install-update -a? It would just be an additional column retrieving from cargo-update's list of crates with --enforce-lock turned on.

nabijaczleweli commented 3 years ago

You can view the configuration for a specific package by running cargo install-update-config [package] and for all packages by listing ~/.cargo/.install_config.toml; there's too much configuration (indeed, why it'd be relevant in an update status table is beyond me) to list it all, and whether lockfiles are enforced is truly not remotely relevant there (you could make the argument for prerelease-resolving state, but the derivative of that is already displayed when needed, so).

nth10sd commented 3 years ago

Got it, this helps a lot. Thank you for adding the support!