rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.12k stars 880 forks source link

rustup fails to open non-existing windows registry path #3779

Closed fruzitent closed 4 days ago

fruzitent commented 5 months ago

Verification

Problem

https://github.com/rust-lang/rustup/blob/1.27.0/src/cli/self_update/windows.rs#L420-L423

Steps

$ docker run --rm -it mcr.microsoft.com/windows/nanoserver:ltsc2022

C:\>reg query HKCU
HKEY_CURRENT_USER\Console
HKEY_CURRENT_USER\Control Panel
HKEY_CURRENT_USER\Network
HKEY_CURRENT_USER\SOFTWARE

C:\>curl --location --remote-name --remote-header-name "https://static.rust-lang.org/rustup/archive/1.27.0/x86_64-pc-windows-msvc/rustup-init.exe"

C:\>.\rustup-init.exe -y
warning: installing msvc toolchain without its prerequisites
error: Failed opening Environment key: The system cannot find the file specified. (os error 2)

Possible Solution(s)

C:\>reg add HKCU\Environment

Notes

No response

Rustup version

rustup-init 1.27.0 (bbb9276d2 2024-03-08)

Installed toolchains

unknown

OS version

Microsoft Windows [Version 10.0.20348.2402]
ChrisDenton commented 5 months ago

Just to provide some more context, nanoserver is a kind of minimal Windows install that would not be expected to have everything the desktop or full server OS does.

rami3l commented 5 months ago

Currently we use open_subkey for all Environment related stuff, do in theory replacing that with create_subkey will do.

I'm not sure about the right direction to go though... The most harmless approach would probably be prompting our users to create it on error, but we cannot test this behavior on standard Windows either.

Update: Looks like nothing is stopping me from running the Rustup CI in the nanoserver image, even if it's just for this particular issue. If the perf overhead is negligible, we might even keep it that way.

fruzitent commented 5 months ago

running the Rustup CI in the nanoserver image

for msvc toolchain you would have to use the next tier image - servercore (4.5gb), because nanoserver (300mb) does not support running 32-bit executables and .NET Framework used in VS Installer, but i tested gnu toolchain with llvm-mingw, works well.