When the total length of the arguments + executable (+ null terminator etc.) exceeds 32,767 Bazel fails ungracefully with the error
Action failed to execute: java.io.IOException: CreateProcess(): The parameter is incorrect.
It would be nice if this had a better error message, at least.
Generally this is pretty worrying because Bazel seems to like creating very large argument lists and this definitely something Bazel can just "fix" :) I've been able to solve my specific case with param files but I think there should be an error message so folks know what's up.
In foo.bzl:
def _broken(ctx):
dummy = ctx.actions.declare_file("dummy.txt")
ctx.actions.run(
outputs = [dummy],
executable = "echo",
arguments = ["x"*32760],
)
broken = rule(
implementation = _broken,
outputs = {"foo": "dummy.txt"},
)
In a BUILD:
load("//:foo.bzl", "broken")
broken(name = "whoops")
Changing 32760 to something lower (e.g. 32759) causes the build to fail for legitimate reasons.
bazel info release): release 0.7.0The following issues may be related. They both contain the same error message (CreateProcess(): The parameter is incorrect) and the one's log showed what appeared to be a 51k long process creation.
CreateProcess which documents the 32,767 restrictionThanks for reporting this bug!
I started seeing the same error a few days ago when building Bazel itself. I'll investigate.
I noticed it while trying to get my Windows build of Bazel to run too, I think during some test coverage stuff (I haven't looked too closely yet.)
In 0.8.0 the error message now looks like:
Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(410): nativeCreateProcess(csc.exe): The filename or extension is too long.
0.8.0 doesn't yet contain https://github.com/Androbin/bazel/commit/b110dfb5cca8961051426e669566cc3aeeac55ee .
We also need your PR (https://github.com/bazelbuild/bazel/pull/4088) with the Java-side changes, so the Java code won't even attempt to create a process if it knows the cmdline is too long.
I figured that one situation where Bazel produces this error is with Java header compilation. Bazel tries to compile all headers in one action, passing all files as arguments. If that fails, Bazel just retries using parameter files. That's why the error is non-fatal, see issue #4096.
Dropping to P2, because Bazel still displays error messages making this a problem with usability, the errors are benign so Bazel is usable.
I think this is a duplicate of https://github.com/bazelbuild/bazel/issues/4096.