rustup self update doesn't update DisplayVersion
Problem
When updating rustup from a prior release using rustup update, the DisplayVersion in the registry isn't updated from the old release version. This will result in tools like winget thinking rustup is outdated, and might confuse users.
Steps
- Install an older release of rustup that sets DisplayVersion such as 1.26.0
- Run
rustup update, and check that rustup is updated to the latest version - Open the "Uninstall a program" menu in control panel or check
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Rustupin the registry to see the outdated version number
Possible Solution(s)
Maybe do_add_to_programs isn't called for updates? I haven't checked the code yet.
Notes
Related to #3047 and #3055
Rustup version
rustup 1.27.0 (bbb9276d2 2024-03-08)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.77.0 (aedd173a2 2024-03-17)`
Installed toolchains
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\User\.rustup
stable-x86_64-pc-windows-msvc (default)
rustc 1.77.0 (aedd173a2 2024-03-17)
@ave9858 Thanks for filing this issue!
Unfortunately I don't currently use Windows and I wonder how exactly winget expect DisplayVersion to change, and I'm curious about how we would be able to verify the fix if it's ever made. @jedieaston maybe you as the original author of #3047 can provide more context on this one?
https://github.com/rust-lang/rustup/pull/3047/files only handles the addition of DisplayVersion on installation. I think running do_add_to_programs() during a self update may be overwhelming though, and a better thing to do would be extracting the addition into a function and use it in both rustup-init and rustup self update.
Also cc @ChrisDenton as our resident Windows expert?
Looking at https://github.com/rust-lang/rustup/blob/0c501d55c54031a992395078d535b6d2574dc693/src/cli/self_update/windows.rs#L503 @rami3l's plan looks good to me. It seems like updating the DisplayVersion would be enough but I guess the only tricky thing would be to make sure it doesn't overwrite another installation of rustup. Not that rustup particularly supports having two concurrent installs.
@ave9858 A new beta release is available, would you mind trying it out?
@ave9858 A new beta release is available, would you mind trying it out?
Still seeing the old version number in control panel after updating to the beta, and I confirmed the old number is shown in the registry also. I first installed Rustup 1.27.0 (via update from 1.26.0 and normal install from https://www.rust-lang.org/tools/install) and then enabled beta via set RUSTUP_UPDATE_ROOT=https://dev-static.rust-lang.org/rustup in cmd. After, I ran rustup self update and saw the version number didn't change.
Looks like a downgrade triggered by removing the RUSTUP_UPDATE_ROOT env var will set the version correctly. Tested by installing 1.26.0, updating to 1.27.0 (display version not updated), updating to 1.27.1 (display var not updated), then running rustup self update in a shell without the variable set, which downgrades to 1.27.0 and updates the display version.
Looks like a downgrade triggered by removing the
RUSTUP_UPDATE_ROOTenv var will set the version correctly. Tested by installing 1.26.0, updating to 1.27.0 (display version not updated), updating to 1.27.1 (display var not updated), then runningrustup self updatein a shell without the variable set, which downgrades to 1.27.0 and updates the display version.
Then it's working as expected (the code changes wasn't there in v1.27.0 so those particular upgrades won't work, but all the upgrades performed on v1.27.1+ should work). Thanks!