-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Windows: shell script cannot be used as an 'executable' for an action #3589
Description
This is an attempt to fix command line limit problem reported in #3579. It's usual approach to work with a response file. So I adapted the code in question from passing the whole 25k command, that was truncated on 8191 character directly to ctx.action(), that was going through the shell:
ctx.action(
inputs = inputs,
outputs = [war],
mnemonic = 'WAR',
command = '\n'.join(cmd),
use_default_shell_env = True,
)with an intermediate step, generated shell script and pass it as executable to ctx.action() instead:
# Executable script to generate war archive
gen_war = ctx.new_file(ctx.label.name + "_gen_war.sh")
ctx.file_action(gen_war, '\n'.join(cmd), True)
ctx.action(
inputs = inputs,
outputs = [war],
mnemonic = 'WAR',
executable = gen_war,
use_default_shell_env = True,
)This works as expected on Linux, but is failing on Windows with:
CreateProcess(): %1 is not a valid Win32 application.
I would expect that Bazel does some heuristic here and guess that the passed file is a shell script, for example, by trying to parse the first file line and see whether or not the first line is a shebang or something and shell out instead of trying to pass previously generated shell script directly to create process.