btest icon indicating copy to clipboard operation
btest copied to clipboard

BTest fails if WSL2 is installed on Windows

Open timwoj opened this issue 1 year ago • 1 comments

I recently installed Docker Desktop on Windows which required the installation of WSL2 so I could run VMs. Having that installed results in the following when trying to run btest from inside a gitbash shell:

$ btest -d bifs.all_set
<3>WSL (11) ERROR: CreateProcessEntryCommon:368: getpwuid(0) failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:372: getpwuid(0) failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:574: execvpe /bin/bash failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:583: Create process not expected to return
<3>WSL (14) ERROR: CreateProcessEntryCommon:368: getpwuid(0) failed 2
<3>WSL (14) ERROR: CreateProcessEntryCommon:372: getpwuid(0) failed 2
<3>WSL (14) ERROR: CreateProcessEntryCommon:574: execvpe /bin/bash failed 2
<3>WSL (14) ERROR: CreateProcessEntryCommon:583: Create process not expected to return
<3>WSL (17) ERROR: CreateProcessEntryCommon:368: getpwuid(0) failed 2
<3>WSL (17) ERROR: CreateProcessEntryCommon:372: getpwuid(0) failed 2
<3>WSL (17) ERROR: CreateProcessEntryCommon:574: execvpe /bin/bash failed 2
<3>WSL (17) ERROR: CreateProcessEntryCommon:583: Create process not expected to return
bifs.all_set ... failed
  % 'zeek -b D:/repos/zeek/testing/btest/.tmp/bifs.all_set/all_set.zeek >out' failed unexpectedly (exit code 1)
  % cat .stderr
  fatal error: can't find base/init-bare.zeek

1 of 1 test failed

The reason here is that it's trying to execute WSL2's bash, but a root user doesn't exist because there isn't a Linux actually installed so there aren't any users. This is easily fixed by executing wsl.exe --install Ubuntu and wsl.exe --setdefault Ubuntu. At this point, bash.exe from WSL2 works and a root user exists. Unfortunately, this still doesn't fix btest:

$ btest -d bifs.all_set
/bin/bash: line 1: C:/Users/timwo/AppData/Local/Temp/tmpychtyig2.sh: No such file or directory
/bin/bash: line 1: C:/Users/timwo/AppData/Local/Temp/tmp2cmnkk4i.sh: No such file or directory
/bin/bash: line 1: C:/Users/timwo/AppData/Local/Temp/tmpa7mxr6mf.sh: No such file or directory
bifs.all_set ... failed
  % 'zeek -b D:/repos/zeek/testing/btest/.tmp/bifs.all_set/all_set.zeek >out' failed unexpectedly (exit code 1)
  % cat .stderr
  fatal error: can't find base/init-bare.zeek

1 of 1 test failed

Next we run into the problem where calling bash.exe from inside Python executes the first bash encountered on the PATH. On my system, that means bash from WSL2 gets executed. The assumptions made that gitbash would be the shell executed, and certain things like paths and such would work, but clearly those assumptions are violated.

timwoj avatar Mar 31 '23 18:03 timwoj