Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build Error][Getting Started] File Path Mismatch in Registry Value (value from get_ucrt_dir vs actual value) #405

Open
miknai opened this issue Sep 4, 2023 · 3 comments

Comments

@miknai
Copy link

miknai commented Sep 4, 2023

TL;DR
The file path from get_ucrt_dir didn't match the file path from the used registry value in my PC (Windows OS).

I was stepping through the Getting Started page as a new Buck2 user. Even though followed every step, I encountered the error saying FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Program Files\\Windows Kits\\10\\Lib' while doing buck2 build //:main. I took a look at vswhere.py code below and found out that the file path that get_ucrt_dir function finds with KitsRoot10 registry key was different from the actual file path that has the library folder it looks for in my PC.

Expected file path from `get_ucrt_dir`: C:\Program Files\Windows Kits\10
The actual file path for the Windows Kits: C:\Program Files (x86)\Windows Kits\10

I updated the registry value on my PC, so now the buck2 build works fine. Maybe, a warning should be added in the Getting Started instruction in case other folks get into a similar situation.

# <path>\buck2\examples\hello_world\prelude\toolchains\msvc\vswhere.py
def get_ucrt_dir():
    registry = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    key_name = "SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots"
    registry_key = winreg.OpenKey(registry, key_name)
    kits_root = Path(winreg.QueryValueEx(registry_key, "KitsRoot10")[0])

    available_versions = [
        entry.name
        for entry in kits_root.joinpath("lib").iterdir()
        if entry.name.startswith("10.") and entry.joinpath("ucrt").is_dir()
    ]

    max_version = max(available_versions) if available_versions else None
    return kits_root, max_version
@miknai miknai changed the title [Build Error][Getting Started] Registry value mismatch (value from get_ucrt_dir vs actual value) [Build Error][Getting Started] File Path Mismatch in Registry Value (value from get_ucrt_dir vs actual value) Sep 4, 2023
@KapJI
Copy link
Member

KapJI commented Sep 4, 2023

Did you install toolchain with Visual Studio installer? We expect it to add these registry keys.

@miknai
Copy link
Author

miknai commented Sep 4, 2023

@KapJI Yes, the toolchain was installed via VS installer before I got the error.

@alexlian
Copy link
Contributor

Expected file path from get_ucrt_dir: C:\Program Files\Windows Kits\10
The actual file path for the Windows Kits: C:\Program Files (x86)\Windows Kits\10

Wondering if it's the 64 bit vs 32 bit registry?
Is it different under the WOW6432Node?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants