nabijaczleweli / cargo-update

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

Remember selected features from install #145

Closed alpha-tango-kilo closed 4 years ago

alpha-tango-kilo commented 4 years ago

Disclaimer: I'm not entirely sure how in-scope this is for this project and/or if it's possible, it's just something I observed trying to update this evening

The problem occurred when I tried to update cargo-lock. By default, cargo-lock is only a library, to access the CLI cargo extension you need the feature "cli". So, when I had installed this I ran the command cargo install cargo-lock --features=cli. No biggie.

However, when then trying to update with cargo install-update -a, this feature isn't retained and default features are compiled so in this case it errored as no binary was produced to install. Obviously this is an edge case where forgetting a feature flag causes a hard error, but I still think it could be useful if this project could remember the feature flags compiled with on install (or have a way for the user to configure them) so that you get what you're expecting when you update.

Hope that made sense, awesome tool, thank you!

nabijaczleweli commented 4 years ago

Thank you for the detailed report!

The way to configure this is with cargo-install-update-config(1) like so:

cargo install-update-config cargo-lock -f cli

This will store your configuration in ~/.install_config.toml.

As for the historical note:

When written (and for a long time since), there was no way to guess this from previous installations (indeed, all the state Cargo used to have for this was ~/.crates.toml; here's the head of that file for me, it's quite literally the bare minumum):

[v1]
"cargo-cache 0.5.1 (git+https://github.com/matthiaskrgr/cargo-cache#5f9fc7c3a8c5d66132f3cb364fac38b26029642f)" = ["cargo-cache"]
"cargo-deb 1.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-deb"]

Hence cargo-install-update-config(1), which you can use to manage all install-time crate-related state cargo-update understands.

Recent Cargos also have a ~/.crates2.json, which does store most of the information kept in ~/.install_config.toml (I wonder if this was convergent evolution or blatant theft, now I think about it), but I haven't implemented anything relating to that. I probably should at some point, but that'd require writing another parser and probably fixing even more Cargo bugs, and I don't have much energy for life nowadays.

alpha-tango-kilo commented 4 years ago

Wow thanks for the quick and detailed response!

I really should have taken a look at the man pages - I just didn't really expect there to be any for a cargo install honestly.

Cheers!

Oooh I'll just tack on a quick question here - is it possible to relocate this tool's ~/.install_config.toml? I like to try and keep ~ clean where possible

nabijaczleweli commented 4 years ago

Urgh, typo: it lives in ~/.cargo/.install_config.toml, next to .crates.toml and friends.