nabijaczleweli / cargo-update

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

cargo-binstall is not used if ~/.cargo/.crates2.json exists #274

Closed dimfeld closed 1 month ago

dimfeld commented 1 month ago

I believe this broke with the recent addition from from_transient to PackageConfig. from_transient is true when .crates2.json exists, and so the comparison between the config and its default returns false when deciding to use binstall or not.

I cloned the code and added a few print statements to verify that this was the problem.

To reproduce:

# Remove .crates2.json if it exists
rm -f ~/.cargo/.crates2.json
# Install an old version of bat
cargo binstall bat --version 0.23.0
# Run cargo install so that .crates2.json will be written
cargo install du-dust
# Update bat, and see that cargo-binstall is not used
cargo install-update bat

Most obvious fix would be to skip the from_transient field when comparing the configs, but I don't know if that's actually the proper fix.

Workaround: Delete ~/.cargo/.crates2.json and don't use cargo-install

nabijaczleweli commented 1 month ago

This should be fixed in v14.0.1 I think? What version of cargo-update do you have?

dimfeld commented 1 month ago

Latest version, 14.1. Also tested against latest main although I think they're identical.

edit: I think this broke in 14.0.2

nabijaczleweli commented 1 month ago

they are... and it would be, yes. we check if !config || config == default, and default config.from_transient is false, so if there is an empty transient config, then that check fails yeah

nabijaczleweli commented 1 month ago

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

dimfeld commented 1 month ago

Yes, that worked. Thanks!

nabijaczleweli commented 1 month ago

Released in v14.1.1