Troubleshooting guide for Bazel-on-Windows?

909 views
Skip to first unread message

Steven Johnson

unread,
Dec 1, 2016, 2:40:26 PM12/1/16
to bazel-discuss
I feel like an idiot for asking so many questions about Bazel-on-Windows, but I remain stubbornly unable to get it to actually work, even on trivial examples.

I'm trying to compile C++ using VS2015; AFAICT I have configured everything according to the directions, but clearly something is amiss, as building even a "Hello-World" C++ project using  --cpu=x64_windows_msvc will fail  with a generic "The system cannot find the path specified" error.

Given that lots of other people are apparently using it with success on Windows, I'm clearly holding it wrong, but am at a bit of a loss as to how best to diagnose what's wrong. If there exists any other troubleshooting/configuration guide(s) for Bazel-for-Windows, I'd appreciate a pointer to it.

(This is using the choco-installed 0.4.1 release, installed for msys2, BTW.)


Zalán Meggyesi

unread,
Dec 1, 2016, 4:23:39 PM12/1/16
to bazel-discuss
Can you post a directory tree and the command you're using to kick off the build?

My guess, off the top of my head, is that you're issuing a build target that doesn't actually exist. Either that, or one of the shell vars is wrong. Depends on the exact file that is not being located...

Steven Johnson

unread,
Dec 1, 2016, 4:40:28 PM12/1/16
to Zalán Meggyesi, bazel-discuss
Source tree:
WORKSPACE:
workspace(name = "example")

BUILD:
cc_binary(name="example", srcs=["example.cpp"])

example.cpp:
#include <stdio.h>

int main(int argc, char** argv) {
printf("Hello, world.\n");
return 0;
}

Command in msys2:
$ bazel build example --cpu=x64_windows_msvc --verbose_failures

Output:
Extracting Bazel installation...
ERROR: CreateFile(C:\tools\msys64\tmp\Bazel\CAAOlKMs\install): The system cannot find the file specified. (2)
.........................
INFO: Found 1 target...
ERROR: C:/src/github/Example/BUILD:1:1: C++ compilation of rule '//:example' failed: msvc_cl.bat failed: error executing command
  cd C:/tools/msys64/tmp/Bazel/CAAOlKMs/execroot/Example
  SET PATH=external/local_config_cc/wrapper/bin
  external/local_config_cc/wrapper/bin/msvc_cl.bat -m64 /D__inline__=__inline /DOS_WINDOWS=OS_WINDOWS /DCOMPILER_MSVC /DNOGDI /DNOMINMAX /DPRAGMA_SUPPORTED /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS /D_USE_MATH_DEFINES /nologo /bigobj /Zm500 /J /Gy /GF /W3 /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /DNDEBUG /Od -Xcompilation-mode=fastbuild /I. /Ibazel-out/vc_14_0_x64-fastbuild/genfiles /Iexternal/bazel_tools /Ibazel-out/vc_14_0_x64-fastbuild/genfiles/external/bazel_tools /Iexternal/bazel_tools/tools/cpp/gcc3 /DEPENDENCY_FILE bazel-out/vc_14_0_x64-fastbuild/bin/_objs/example/example.d /c example.cpp /Fobazel-out/vc_14_0_x64-fastbuild/bin/_objs/example/example.o: com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
The system cannot find the path specified.
Target //:example failed to build
INFO: Elapsed time: 25.131s, Critical Path: 0.41s



--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/07b8c1ed-e6f1-4990-b59e-d67a44dcadb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zalán Meggyesi

unread,
Dec 1, 2016, 5:38:16 PM12/1/16
to bazel-discuss, zmeg...@skawa.hu
My theory, based on this input, is that the MSVC var is not set in the shell and Bazel is looking for the batch file in the wrong place.

I had a similar problem myself, even though I was building Java, but I still needed a copy of VS and had to add the path (tried an empty string to suppress the error, but didn't work).
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Steven Johnson

unread,
Dec 1, 2016, 5:45:43 PM12/1/16
to Zalán Meggyesi, bazel-discuss
$ echo $BAZEL_VS
C:\Program Files (x86)\Microsoft Visual Studio 14.0

Is there something other than BAZEL_VS that needs to be set?


To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/7dd80731-489b-4aee-90f4-ea877f756cf9%40googlegroups.com.

Yun Peng

unread,
Dec 1, 2016, 6:10:24 PM12/1/16
to Steven Johnson, Zalán Meggyesi, bazel-discuss
Hi Steven,

That seems to be a weird error, let's see if the c++ toolchain configuration is right.
Can you show me the directory tree of  C:/temp/Bazel/YkOeLt4r/external/local_config_cc?
In msys, you can do 
$ pacman -S tree
$ tree C:/temp/Bazel/YkOeLt4r/external/local_config_cc

Thanks,
Yun



--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Steven Johnson

unread,
Dec 1, 2016, 6:21:35 PM12/1/16
to Yun Peng, Zalán Meggyesi, bazel-discuss
I have no such directory. Where did "YkOeLt4r" come from? (FWIW, I don't even have a c:\temp directory.)

To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.

Zalán Meggyesi

unread,
Dec 1, 2016, 6:23:49 PM12/1/16
to bazel-discuss, pcl...@google.com, zmeg...@skawa.hu
It should actually be in the MSYS /var/tmp/Bazel directory, at least for a regular install. I'm not sure for choco.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Steven Johnson

unread,
Dec 1, 2016, 6:30:05 PM12/1/16
to Zalán Meggyesi, bazel-discuss, Yun Peng
I don't seem to have anything there, either. I do have stuff in C:/tools/msys64/tmp/Bazel/CAAOlKMs that might be what you seek.

To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/dbbd5b42-f32f-483e-9f4a-aa8ef6788e2f%40googlegroups.com.

Steven Johnson

unread,
Dec 1, 2016, 6:31:43 PM12/1/16
to Zalán Meggyesi, bazel-discuss, Yun Peng
$ tree C:/tools/msys64/tmp/Bazel/CAAOlKMs/external/local_config_cc
C:/tools/msys64/tmp/Bazel/CAAOlKMs/external/local_config_cc
├── BUILD
├── CROSSTOOL
├── tools
│   └── cpp
│       └── empty.cc
├── WORKSPACE
└── wrapper
    ├── bin
    │   ├── call_python.bat
    │   ├── msvc_cl.bat
    │   ├── msvc_link.bat
    │   ├── msvc_nop.bat
    │   └── pydir
    │       ├── msvc_cl.py
    │       ├── msvc_link.py
    │       └── msvc_tools.py
    └── get_env.bat

5 directories, 12 files


Yun Peng

unread,
Dec 1, 2016, 7:18:12 PM12/1/16
to Steven Johnson, Zalán Meggyesi, bazel-discuss
Oh, sorry, I did mean C:/tools/msys64/tmp/Bazel/CAAOlKMs/external/local_config_cc

Hmm,, looks like the cc configuration is correct. Can you try to reproduce this in cmd.exe?
1. Open a new cmd.exe
2. cd C:/tools/msys64/tmp/Bazel/CAAOlKMs/execroot/Example
3. SET PATH=external\local_config_cc\wrapper\bin;%PATH%
4. external\local_config_cc\wrapper\bin\msvc_cl.bat -m64 /D__inline__=__inline /DOS_WINDOWS=OS_WINDOWS /DCOMPILER_MSVC /DNOGDI /DNOMINMAX /DPRAGMA_SUPPORTED /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS /D_USE_MATH_DEFINES /nologo /bigobj /Zm500 /J /Gy /GF /W3 /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /DNDEBUG /Od -Xcompilation-mode=fastbuild /I. /Ibazel-out/vc_14_0_x64-fastbuild/genfiles /Iexternal/bazel_tools /Ibazel-out/vc_14_0_x64-fastbuild/genfiles/external/bazel_tools /Iexternal/bazel_tools/tools/cpp/gcc3 /DEPENDENCY_FILE bazel-out/vc_14_0_x64-fastbuild/bin/_objs/example/example.d /c example.cpp /Fobazel-out/vc_14_0_x64-fastbuild/bin/_objs/example/example.o


The command I gave is not exactly the same as Bazel outputed, but it should work in cmd.exe


Steven Johnson

unread,
Dec 1, 2016, 7:29:45 PM12/1/16
to Yun Peng, Zalán Meggyesi, bazel-discuss
Nope, I still get "The system cannot find the path specified." -- but doing that seems to have led me to the issue:

I had defined BAZEL_PYTHON using Bash-style paths (/c/Python27/python.exe), figuring that would be the right thing to do in a bash-ish environment. Apparently it really needs a Windows-style path (C:/Python27/python.exe).

(I wonder if it would make sense to reality-check the values of these variables to be sure they look sensible?)


To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.

Yun Peng

unread,
Dec 2, 2016, 1:36:14 AM12/2/16
to Steven Johnson, Zalán Meggyesi, bazel-discuss
Ah, I see. So setting BAZEL_PYTHON=C:/Python27/python.exe should fix the problem.
Our goal is to make Bazel as a native tool on Windows, you can actually set all those environment variables and run bazel in cmd.exe
So I think it makes more sense to set it as a Windows style path.

But yes, we should check this and output more useful error message for users. Thanks for raising this issue!

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Steven Johnson

unread,
Dec 2, 2016, 12:12:32 PM12/2/16
to Yun Peng, Zalán Meggyesi, bazel-discuss
On Thu, Dec 1, 2016 at 10:36 PM, Yun Peng <pcl...@google.com> wrote:
Our goal is to make Bazel as a native tool on Windows, you can actually set all those environment variables and run bazel in cmd.exe

That's good to hear, but I guess I'm confused: I thought that the msys2 environment was (more or less) required for use at this stage. (The install instructions seem to indicate that.)

 

Yun Peng

unread,
Dec 2, 2016, 12:18:07 PM12/2/16
to Steven Johnson, laszlo...@google.com, Zalán Meggyesi, bazel-discuss
That's because Bazel itself is built with gcc toolchain in MSYS, so the Bazel binary still depend on msys-2.0.dll. As long as that dll is in PATH, we can use Bazel from cmd.exe

+László Csomor is working actively on getting rid of msys dependency to make it possible to build Bazel with MSVC toolchain. Please see https://github.com/bazelbuild/bazel/issues/2107 :)

Reply all
Reply to author
Forward
0 new messages