Skip to content

The agent that grows with you

fix(desktop): read VCToolsVersion BOM-tolerantly; match vswhere as a path

ethernet84b1f0531350
diff --git a/scripts/bundles/desktop_toolchain.py b/scripts/bundles/desktop_toolchain.py
index fa5e9690d33..7652959d793 100644
--- a/scripts/bundles/desktop_toolchain.py
+++ b/scripts/bundles/desktop_toolchain.py
@@ -147,7 +147,7 @@ def _msvc_identity() -> dict[str, str] | None:
instance = instances[0]
tools = Path(instance["installationPath"], "VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt")
return {"installationVersion": instance["installationVersion"],
- "VCToolsVersion": tools.read_text(encoding="utf-8").strip()}
+ "VCToolsVersion": tools.read_text(encoding="utf-8-sig").strip()}
except (OSError, subprocess.TimeoutExpired, ValueError, IndexError, KeyError) as error:
print(f"warning: MSVC cache identity unavailable: {error}", file=sys.stderr, flush=True)
return None
diff --git a/tests/scripts/test_desktop_toolchain.py b/tests/scripts/test_desktop_toolchain.py
index 393d59eb15a..59fdf1b8570 100644
--- a/tests/scripts/test_desktop_toolchain.py
+++ b/tests/scripts/test_desktop_toolchain.py
@@ -306,7 +306,7 @@ def test_native_cache_is_stable_without_a_developer_environment(tmp_path, monkey
install = tmp_path / "vs"
version_file = install / "VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt"
version_file.parent.mkdir(parents=True)
- version_file.write_text("14.44.35207\n", encoding="utf-8")
+ version_file.write_text("\ufeff14.44.35207\n", encoding="utf-8") # Visual Studio writes a BOM
vswhere = json.dumps([{"installationPath": str(install), "installationVersion": "17.14.1"}])
# vswhere is never on PATH; hermes_platform finds it in the installer directory.
installer = tmp_path / "Program Files (x86)/Microsoft Visual Studio/Installer"
@@ -316,7 +316,8 @@ def test_native_cache_is_stable_without_a_developer_environment(tmp_path, monkey
monkeypatch.setenv("PATH", "")
def probe(command, **kwargs):
- stdout = vswhere if command[0] == str(installer / "vswhere.exe") else "rustc 1.98.0"
+ # The resolver joins its known dir with mixed separators; compare as paths.
+ stdout = vswhere if Path(command[0]) == installer / "vswhere.exe" else "rustc 1.98.0"
return SimpleNamespace(returncode=0, stdout=stdout, stderr="")
desktop_toolchain.platform.platform()