rustup
rustup copied to clipboard
Add DisplayVersion for rustup to registry on Windows.
Hello! I'm a contributor to the Windows Package Manager Community Repository (microsoft/winget-pkgs), and we recently had an issue posted to that repo which revealed that Rustup was not publishing a DisplayVersion to Add and Remove Programs during its install (although it was posting its DisplayName).
The DisplayVersion is how winget and other tools determine when updates to software are needed, so it is highly recommended to set it whenever possible. This PR does just that, by making it so when Rustup is installed, it adds its version number to the registry alongside its name.
This is the most Rust I've ever written, so let me know if I did something wrong and I can fix it :)
Tested: manually by compiling a new version of Rustup and installing it in a VM. If this needs more strenuous tests, I'm happy to oblige.
Resolves: https://github.com/rust-lang/rustup/issues/3055
Thanks @jedieaston
I had exactly the same issue. My approach is slightly different:
key.set_value("DisplayVersion", &common::version())
.context("Failed to set display version")?;
Note that this sets the version in the form as outputted by rustup --version (i.e. it includes the commit hash and release date). As long as every new release changes either one of the major.minor.patch numbers that shouldn't be a problem.
We prefer for there not to be extraneous information in the DisplayVersion outside of the number on the winget side, as it makes it easier to do comparisons for upgrades. If it is common to do multiple releases of Rustup under the same exact version number I can change it, but I think any stable releases would increment the CARGO_PKG_VERSION which is always just a number (at least, according to this).