2

I have jenkins set up on a windows 10 computer that has WSL (Windows Subsystem for Linux). When I run, for example, from the terminal the simple command ""C:\Windows\System32\wsl.exe" --help" it works fine. Doing the same as a step on jenkins with a windows batch command, I get the exit code-1073740791.

I have tried the following solutions that did not worked out:

-From a tip that it would not be allowed to run on System32, I tried copying the executable to another folder outside System32, but I get the same error;

-From another research, could be running under 32 bit, since the cmd is 64 bit, so I tried calling from the Sysnative "C:\Windows\Sysnative\wsl.exe", but I get file not found;

Also: Sometime ago I had a similar issue running the bash.exe from the System32, solved it by using another bash.exe (grom gitbash).

Any hints on how to overcome this problem? I really need to run WSL to compile some projects in jenkins jobs.

Thank you for your time.

João P.
  • 55
  • 6

1 Answers1

0

Not sure whether this is the answer or not (it may be), but the explanation and troubleshooting are a bit long for a comment.

It sounds like you may be on the right track with 32-bit vs 64-bit, but possibly a bit confused on which apps are which architecture.

On 64-bit Windows 10, wsl.exe is always 64-bit. You can see this (assuming you have put it back in the right place) via:

> file /mnt/c/Windows/System32/wsl.exe
/mnt/c/Windows/System32/wsl.exe: PE32+ executable (console) x86-64, for MS Windows

Moving it doesn't change the architecture, of course.

since the cmd is 64 bit

It's really the architecture of Java and Jenkins that you need to worry about. Is your Java 32-bit or 64-bit?

> file "$(command -v java.exe)"
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath/java.exe: PE32 executable (console) Intel 80386, for MS Windows

I don't run much Java at the moment, but I happened to have a release installed from a while back on one of my systems. Turns out it is 32-bit.

If your java.exe is 32-bit, then this would most likely explain why you can't run wsl.exe, which is 64-bit.

-From another research, could be running under 32 bit, since the cmd is 64 bit, so I tried calling from the Sysnative "C:\Windows\Sysnative\wsl.exe", but I get file not found;

I assume that you are referring to this answer or something similar. It sounds like you may have tried that from CMD. Let's do that here for reference:

>C:\Windows\Sysnative\wsl.exe

The system cannot find the path specified.

> wsl.exe

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

>

This is correct, since both CMD and WSL are 64-bit. The purpose of Sysnative is to allow you to call a 64-bit from a 32-bit app.

However, if you try that from a 32-bit application, it should work. Try from "Windows PowerShell (x86)":

> wsl.exe

wsl.exe : The term 'wsl.exe' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ wsl.exe
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (wsl.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

> C:\Windows\Sysnative\wsl.exe
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

>

If you try that path from within Jenkins (assuming it is 32-bit), what do you get?

If C:\Windows\Sysnative\wsl.exe doesn't work for you from Jenkins, and assuming your Java is 32-bit, do you have the option to run 64-bit Java for this task?

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
  • 1
    Thank you for your detailed response. Java is 64 bit and when I run on jenkins "C:\Windows\Sysnative\wsl.exe" it does not find it, so I guess the problem is not here. Could it be any jenkins configuration that does not allow it to run System32 applications? I read some comments about "You cannot open windows processes through Jenkins running as a service". – João P. Dec 10 '21 at 11:58
  • @JoãoP. Bummer - If it's something specific to Jenkins, I won't be able to try it out. If you happen to find those comments again, can you link them in a reply to me, and I can at least see if I can think of a hack-around? Thanks! – NotTheDr01ds Dec 10 '21 at 12:45
  • 1
    Sure, some of those comments were from [this](https://stackoverflow.com/a/16310502/11299409) and [this](https://stackoverflow.com/a/57154624/11299409) – João P. Dec 10 '21 at 12:59