I'm starting bazelisk with such a command line:
build --remote_download_outputs=all --target_pattern_file "C:\Users\User Name\..."
and it uses a batch script which is also located inside the 'C:\Users\User Name' folder.
I'm getting the following error:
'C:\Users\User' is not recognized as an internal or external command, operable program or batch file.
It happens due to the batch wrapper, everything works fine if I set BAZELISK_SKIP_WRAPPER or remove the wrapper.
I have investigated it and found that syscall.StartProcess() that is called through some intermediate layers from bazelisk's core.runBazel(), specifies both lpApplicationName and lpCommandLine for CreateProcessW WinAPI function. But it's an unreliable way to start a batch script, it works in some simple cases and fails in others, such as the one that I described above.
Batch scripts should be started in the following way according to CreateProcessW documentation:
To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the batch file.
It would also be ok to just skip lpApplicationName and Windows would be able to find the interpreter automatically, but unfortunately, the Go standard library doesn't allow to omit exec.Cmd.Path.
So, the only proper way available for us in Go is using cmd.exe explicitly.
I'm starting
bazeliskwith such a command line:and it uses a batch script which is also located inside the 'C:\Users\User Name' folder.
I'm getting the following error:
It happens due to the batch wrapper, everything works fine if I set
BAZELISK_SKIP_WRAPPERor remove the wrapper.I have investigated it and found that
syscall.StartProcess()that is called through some intermediate layers from bazelisk'score.runBazel(), specifies bothlpApplicationNameandlpCommandLinefor CreateProcessW WinAPI function. But it's an unreliable way to start a batch script, it works in some simple cases and fails in others, such as the one that I described above.Batch scripts should be started in the following way according to CreateProcessW documentation:
It would also be ok to just skip
lpApplicationNameand Windows would be able to find the interpreter automatically, but unfortunately, the Go standard library doesn't allow to omitexec.Cmd.Path.So, the only proper way available for us in Go is using
cmd.exeexplicitly.