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

find_vc_path fails to detect VS2022 Preview installation #319

Open
mocabe opened this issue Jan 27, 2025 · 0 comments
Open

find_vc_path fails to detect VS2022 Preview installation #319

mocabe opened this issue Jan 27, 2025 · 0 comments

Comments

@mocabe
Copy link

mocabe commented Jan 27, 2025

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.exe is called without -prerelease option, which is required to detect Preview installations.

    result = repository_ctx.execute([vswhere_binary, "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "-property", "installationPath", "-latest"])

  • program_files_dir (C:\\Program Files (x86)) is used for searching installation paths. Since VS2022 is now 64-bit application, C:\\Program Files might be better option here.

    path = program_files_dir + "\\" + path

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
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

1 participant