find_vc_path fails to detect VS2022 Preview installation
Hello, I just started to learn Bazel recently but encountered an issue that Bazel fails detect local installation of VS2022 Preview.
I was able to workaround it by defining envvar BAZEL_VC=C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC, but I believe this should be property detected by find_vc_path.
By looking at code I found several places which might be contributing to this issue:
-
vswhere.exeis called without-prereleaseoption, which is required to detect Preview installations.https://github.com/bazelbuild/rules_cc/blob/96d7d59f1fc928ac78b08e07f1172e5b24fe5dac/cc/private/toolchain/windows_cc_configure.bzl#L177
-
program_files_dir(C:\\Program Files (x86)) is used for searching installation paths. Since VS2022 is now 64-bit application,C:\\Program Filesmight be better option here.https://github.com/bazelbuild/rules_cc/blob/96d7d59f1fc928ac78b08e07f1172e5b24fe5dac/cc/private/toolchain/windows_cc_configure.bzl#L248
Output
...
INFO: Analyzed target //source:main (83 packages loaded, 397 targets configured).
ERROR: ***/source/BUILD.bazel:1:10: Compiling source/main.cpp failed: (Exit 1): vc_installation_error_x64.bat failed: error executing CppCompile command (from target //source:main) external\bazel_tools~cc_configure_extension~local_config_cc\vc_installation_error_x64.bat @bazel-out/x64_windows-dbg/bin/source/_objs/main/main.obj.params
The target you are compiling requires Visual C++ build tools.
Bazel couldn't find a valid Visual C++ build tools installation on your machine.
Please check your installation following https://bazel.build/docs/windows#using
Target //source:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 4.531s, Critical Path: 0.10s
INFO: 6 processes: 6 internal.
ERROR: Build did NOT complete successfully
...
Environment
- Windows11
- VS2022 17.13.0 Preview 3.0 (no other versions are installed)
- Bazel 7.2.1