Bazel C++ Toolchain Detection Issue on Windows - protobuf_tools Compilation Fails Despite Visual Studio Build Tools Installed #6252
Operating SystemWindows 11 Android Studio VersionAndroid Studio Panda 2 | 2025.3.2 Build #AI-253.30387.90.2532.14935130 RAM size16 GB Free disk space120 GB free Which step are you stuck on?Following the Oppia Android setup/build process on Windows. The issue occurs during the Bazel build step while running: bazel mobile-install --enable_bzlmod=false //:oppia_dev_binaryThe build analysis phase succeeds, external dependencies download correctly, and Bazel configures all targets. However, the build fails during the Environment details:
I verified that:
The issue appears to happen specifically during Bazel's MSVC/C++ toolchain detection or initialization phase. Error LogBuild reaches analysis and then fails when compiling protobuf C++ sources:
ERROR: C:/users/user/_bazel_user/layajk7g/external/protobuf_tools/BUILD:118:11: Compiling src/google/protobuf/wire_format_lite.cc [for tool] failed: (Exit 1): vc_installation_error_x64.bat failed: error executing command
The target you are compiling requires Visual C++ build tools.
Bazel could not find a valid Visual C++ build tools installation on your machine.Approaches already used to resolve the issue
Additional informationThe issue only occurs during the C++ compilation stage ( The project builds successfully in CI, so this seems to be specific to my local Windows/Bazel setup. Would appreciate any guidance from contributors who have successfully configured Bazel on Windows. |
Replies: 3 comments 2 replies
|
I went through your discussion and I think I can help you out here. So the main thing is oppia-android is not really meant to be built natively on Windows using Visual Studio Build Tools. That is the reason bazel keeps throwing error even though you have set everything correctly. So it is more of a Bazel + Windows limitation, not something wrong from your side. The recommended way to build oppia-android on Windows is using WSL (Windows Subsystem for Linux) with Ubuntu. Once you are inside WSL, you basically follow the Linux instructions and everything works fine, because it uses the Linux GCC toolchain instead of MSVC, so the whole protobuf compile failure just doesn't happen. The wiki you should be referring to is this one Installing Oppia Android. Scroll down to the section called "Bazel Set up for Windows (Not Recommended)", it has the whole thing step by step. Roughly the steps are:
Also one more thing I noticed, you are using Android Studio Panda 2 (2025.3.2), but right now the project does not officially support Panda. Anything from Otter onwards is not compatible with the project because the Bazel plugin used by those versions needs Bazel 7.x+, but oppia-android is still on Bazel 6.5.0. So even after you fix the build issue, the Bazel won't sync properly on Panda. The wiki officially recommends Giraffe, and the latest version known to work is Narwhal 3 Feature Drop (2025.1.3). Since the Windows setup is already a bit tricky, I would suggest just sticking with Giraffe as the wiki says, it will save you a lot of headache. Hope this helps! Let me know if you get stuck somewhere. |
|
Thanks a lot for the detailed explanation! That really helped me understand what was going wrong. I have now switched to the WSL2 + Ubuntu setup and installed Android Studio Giraffe as you suggested. I’m still setting everything up and testing the build flow inside WSL but things are already looking much better compared to the native Windows setup. Really appreciate you taking the time to explain everything so clearly! |
|
@Neer-rn Thank you so much for the detailed guidance and explanations throughout this issue. Your suggestion to switch to WSL2 + Ubuntu instead of continuing with the native Windows setup made a huge difference. I have now completed the setup successfully:
The native Windows + MSVC setup was definitely the root cause here, and moving to the Linux GCC toolchain inside WSL solved the issue almost immediately. |
Hey @saimanoharigodavarty
I went through your discussion and I think I can help you out here.
So the main thing is oppia-android is not really meant to be built natively on Windows using Visual Studio Build Tools. That is the reason bazel keeps throwing error even though you have set everything correctly. So it is more of a Bazel + Windows limitation, not something wrong from your side.
The recommended way to build oppia-android on Windows is using WSL (Windows Subsystem for Linux) with Ubuntu. Once you are inside WSL, you basically follow the Linux instructions and everything works fine, because it uses the Linux GCC toolchain instead of MSVC, so the whole protobuf compile failure just d…