rustup icon indicating copy to clipboard operation
rustup copied to clipboard

rustup fails to open non-existing windows registry path

Open fruzitent opened this issue 10 months ago • 3 comments

Verification

  • [X] I searched for recent similar issues at https://github.com/rust-lang/rustup/issues?q=is%3Aissue+is%3Aopen%2Cclosed and found no duplicates.
  • [X] I am on the latest version of Rustup according to https://github.com/rust-lang/rustup/tags and am still able to reproduce my issue.

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]

fruzitent avatar Apr 19 '24 22:04 fruzitent

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.

ChrisDenton avatar Apr 19 '24 22:04 ChrisDenton

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.

rami3l avatar Apr 20 '24 04:04 rami3l

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.

fruzitent avatar Apr 23 '24 12:04 fruzitent