rustup icon indicating copy to clipboard operation
rustup copied to clipboard

rustup self update doesn't update DisplayVersion

Open ave9858 opened this issue 1 year ago • 3 comments

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

  1. Install an older release of rustup that sets DisplayVersion such as 1.26.0
  2. Run rustup update, and check that rustup is updated to the latest version
  3. Open the "Uninstall a program" menu in control panel or check HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Rustup in 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 avatar Mar 24 '24 20:03 ave9858

@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.

rami3l avatar Mar 25 '24 11:03 rami3l

Also cc @ChrisDenton as our resident Windows expert?

djc avatar Mar 25 '24 12:03 djc

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.

ChrisDenton avatar Mar 25 '24 12:03 ChrisDenton

@ave9858 A new beta release is available, would you mind trying it out?

rami3l avatar Apr 28 '24 00:04 rami3l

@ave9858 A new beta release is available, would you mind trying it out?

image

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.

ave9858 avatar Apr 28 '24 00:04 ave9858

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.

ave9858 avatar Apr 28 '24 01:04 ave9858

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.

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!

rami3l avatar Apr 28 '24 02:04 rami3l