Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTest fails if WSL2 is installed on Windows #91

Open
timwoj opened this issue Mar 31, 2023 · 1 comment
Open

BTest fails if WSL2 is installed on Windows #91

timwoj opened this issue Mar 31, 2023 · 1 comment

Comments

@timwoj
Copy link
Member

timwoj commented Mar 31, 2023

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
Copy link
Member Author

timwoj commented Mar 31, 2023

Just trying to run directly under WSL2 bash doesn't work either:

root:/d/repos/zeek/out/build/x64-Debug# source zeek-path-dev.sh
-bash: /D/repos/zeek/out/build/x64-Debug/zeek-path-dev: No such file or directory
-bash: /D/repos/zeek/out/build/x64-Debug/spicy-path: No such file or directory
-bash: /D/repos/zeek/out/build/x64-Debug/hilti-cxx-include-dirs: No such file or directory
root:/d/repos/zeek/out/build/x64-Debug# ln -s /mnt/d /D
root:/d/repos/zeek/out/build/x64-Debug# source zeek-path-dev.sh
-bash: /D/repos/zeek/out/build/x64-Debug/zeek-path-dev: /bin/sh^M: bad interpreter: No such file or directory
-bash: /D/repos/zeek/out/build/x64-Debug/spicy-path: /bin/sh^M: bad interpreter: No such file or directory
-bash: /D/repos/zeek/out/build/x64-Debug/hilti-cxx-include-dirs: /bin/sh^M: bad interpreter: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant