facebook / facebook/buck2

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

Open
#405 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

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](https://buck2.build/docs/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.

```
# \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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.