nabijaczleweli / cargo-update

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

Avoid installing pre-release updates #112

Closed jmagnuson closed 5 years ago

jmagnuson commented 5 years ago

I've been running into CI issues lately with cargo-audit updating to the v0.9.0-betaN release-candidates that have been coming out, which are unfortunately broken at build and/or run time. cargo-install ignores these (possibly by semver check? I haven't dug into it yet) and instead opts for v0.8.0, and I'm wondering how cargo-update might best handle this.

I personally like doing a semver filter internally (with a switch or something to allow RC updates), but possibly some sort of flag+regex could work too.

nabijaczleweli commented 5 years ago

hmm I'd assume it's semver::Version::is_prerelease(), I guess I can add a config to disable installing them?

jmagnuson commented 5 years ago

I'll likely end up adding the flag to every call I make, but that certainly works for me.

nabijaczleweli commented 5 years ago

hmm, with the commit above prerelease installs are disabled by default, and need be enabled like this:

p:\Rust\cargo-update>target\debug\cargo-install-update install-update -a
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package      Installed  Latest        Needs update
cargo-audit  v0.0.1     v0.9.0-beta2  No

No packages need updating.
Overall updated 0 packages.

p:\Rust\cargo-update>target\debug\cargo-install-update-config install-update-config cargo-audit --install-prereleases
Install prereleases  true
Default features     true

p:\Rust\cargo-update>target\debug\cargo-install-update install-update -a
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package      Installed  Latest        Needs update
cargo-audit  v0.0.1     v0.9.0-beta2  Yes

Updating cargo-audit
    Updating crates.io index
^C

If this works on your end I'll push out a release!

jmagnuson commented 5 years ago
$ cargo install-update --allow-no-update cargo-audit
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package      Installed  Latest        Needs update
cargo-audit  v0.8.1     v0.9.0-beta2  No

No packages need updating.
Overall updated 0 packages.

LGTM, thanks!

nabijaczleweli commented 5 years ago

Released in v2.0.0!

dkim commented 5 years ago

cargo install-update --allow-no-update appears not to work well when the latest version of a package is a pre-release one:

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest       Needs update
cargo-deny             v0.3.0-beta  No

No packages need updating.
Overall updated 0 packages.

Because the package was not installed previously, I expected that the command would install its beta version (or the latest release version).

nabijaczleweli commented 5 years ago

Mind testing with the commit above? This will install the latest non-prerelease version available.

dkim commented 5 years ago

Yes, it works like a charm. If I have to say one thing, it might be more informative to show both of the release/prerelease versions, if any, in the "Latest" field. Thank you for this indispensable tool!

$ cargo install --git https://github.com/nabijaczleweli/cargo-update --rev eef5d04f

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest  Needs update
cargo-deny             v0.2.6  Yes
...
Updated 1 package.
Overall updated 1 package.

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest  Needs update
cargo-deny  v0.2.6     v0.2.6  No

No packages need updating.
Overall updated 0 packages.

$ cargo install-update-config --install-prereleases cargo-deny

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest       Needs update
cargo-deny  v0.2.6     v0.3.0-beta  Yes
...
Updated 1 package.
Overall updated 1 package.

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed    Latest       Needs update
cargo-deny  v0.3.0-beta  v0.3.0-beta  No

No packages need updating.
Overall updated 0 packages.
nabijaczleweli commented 5 years ago

Released in v2.2.0.

As for the dual version thing – sure, if I can come up with a good implementation. But I can't think of one right now, so.

nabijaczleweli commented 5 years ago

I've come up with the following in the above commit:

$ cargo install-update -i cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest                          Needs update
cargo-deny  No         v0.2.6 (v0.3.0-beta available)  Yes

Installing cargo-deny
    Updating crates.io index
    […]

Would be lovely of you try it out and see if there's anything I've missed.

dkim commented 5 years ago

It works very well! 👏

$ cargo install --git https://github.com/nabijaczleweli/cargo-update --rev ecd9db9

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest                          Needs update
cargo-deny  No         v0.2.6 (v0.3.0-beta available)  Yes
...
Updated 1 package.
Overall updated 1 package.

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest                          Needs update
cargo-deny  v0.2.6     v0.2.6 (v0.3.0-beta available)  No

No packages need updating.
Overall updated 0 packages.

$ cargo install-update-config --install-prereleases cargo-deny

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed  Latest       Needs update
cargo-deny  v0.2.6     v0.3.0-beta  Yes
...
Updated 1 package.
Overall updated 1 package.

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed    Latest       Needs update
cargo-deny  v0.3.0-beta  v0.3.0-beta  No

No packages need updating.
Overall updated 0 packages.

It may be better to delete the available word because the field looks a little awkward in the following case. It, however, happens rarely, so may not be worth taking into account.

$ cargo install-update-config --no-install-prereleases cargo-deny
Install prereleases  false
Default features     true

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed    Latest                          Needs update
cargo-deny  v0.3.0-beta  v0.2.6 (v0.3.0-beta available)  No

No packages need updating.
Overall updated 0 packages.
nabijaczleweli commented 5 years ago

Yeah I really prefer consistency over potential awkwardness in that last case. Thank you for testing!

Released in v2.3.0.

dkim commented 5 years ago

I meant omitting "available" consistently in all cases, but the current version is also much more than good enough. 👍

nabijaczleweli commented 5 years ago

oh, in that case I just didn't think the following clearly communicates "available but not chosen"; ah well

$ cargo install-update --allow-no-update cargo-deny
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package     Installed    Latest                Needs update
cargo-deny  v0.3.0-beta  v0.2.6 (v0.3.0-beta)  No