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

Cannot start Windows executable from powershell.exe started from WSL2 after wsl.exe --update #9364

Closed
1 of 2 tasks
0anton opened this issue Dec 18, 2022 · 16 comments
Closed
1 of 2 tasks

Comments

@0anton
Copy link

0anton commented Dec 18, 2022

Version

Windows version: 10.0.19044.2364

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.79.1

Distro Version

Ubuntu 20.04

Other Software

n/a

Repro Steps

$ powershell.exe

PS C:\temp> dir \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey\AutoHotkeyU64.exe



    Directory: \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
------        12/21/2020   2:56 AM        1190400 AutoHotkeyU64.exe


PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey> .\AutoHotkeyU64.exe

Program 'AutoHotkeyU64.exe' failed to run: Incorrect functionAt line:1 char:1
+ .\AutoHotkeyU64.exe
+ ~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ .\AutoHotkeyU64.exe
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed
$ cmd.exe

C:\temp>dir \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey\AutoHotkeyU64.exe
 Volume in drive \\wsl.localhost\Ubuntu-20.04 has no label.
 Volume Serial Number is 0000-0000

 Directory of \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey

21/12/2020  02:56         1.190.400 AutoHotkeyU64.exe
               1 File(s)      1.190.400 bytes
               0 Dir(s)  170.607.165.440 bytes free

C:\temp>\\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey\AutoHotkeyU64.exe
The system cannot execute the specified program.

It is also impossible to open file associated with the executable:

d057039:AutoHotkey|master$ cmd.exe /c start FixCtrlBackspace.ahk
The system cannot execute the specified program.

Expected Behavior

Executing Windows programs on WSL2 paths from cmd.exe or powershell.exe is possible if the latter it started from WSL2 environment (in current example AutoHotkeyU64.exe starts.

Actual Behavior

cmd.exe: The system cannot execute the specified program.
powershell.exe: NativeCommandFailed

Diagnostic Logs

Remarks:

  1. Before the wsl.exe --update cmd.exe and poweshell.exe could start executables on WSL2 paths just same fine as other executables.
  2. WSL2 start Windows executable correctly.
  3. cmd.exe or powershell.exe which are started natively from Windows also start any executable on WSL2 path perfectly.
@Rack1600
Copy link

Rack1600 commented Dec 19, 2022

I am seeing a similar issue, where we use a windows python.exe from WSL, and after wsl --update, processes started from within python.exe fail to run (WindowsError: [Error 1] Incorrect function).
The same python script, run in the same python.exe, but started from within windows, does not fail.
Also, running the process directly from WSL (not via python) also works.
Seems like exactly the same issue, but with python instead of cmd.exe or powershell.exe.

Since my issue is very similar but slightly different (Python instead of cmd or powershell) I have raised another issue. Can I link them?
#9370

@davidtlascelles
Copy link

I also have this issue. I think it may be related to the switch to the Microsoft Store version of WSL

@Rack1600
Copy link

I also have this issue. I think it may be related to the switch to the Microsoft Store version of WSL

@davidtlascelles this worked for me with the store version of WSL. It stopped working yesterday when I ran "wsl --update" and "wsl --shutdown" to get the latest features.

@Rack1600
Copy link

uninstall store version and It will start working again.

I did this and it did not help.
This is blocking my department from using WSL :(

@Rack1600
Copy link

Rack1600 commented Jan 2, 2023

It looks like this:
#9421
could be a variant on this issue too

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 5, 2023

/logs

@OneBlue OneBlue closed this as completed Jan 5, 2023
@ghost
Copy link

ghost commented Jan 5, 2023

Hello! Could you please provide more logs to help us better diagnose your issue?

To collect WSL logs, download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The scipt will output the path of the log file once done.

Once completed please upload the output files to this Github issue.

Click here for more info on logging

Thank you!

@OneBlue OneBlue reopened this Jan 5, 2023
@ghost ghost added the needs-author-feedback label Jan 5, 2023
@Rack1600
Copy link

Rack1600 commented Jan 6, 2023

WslLogs-2023-01-06_13-31-44.zip
Logs of executable failling when run from WSL -> Powershell -> .exe

@Rack1600
Copy link

Rack1600 commented Jan 6, 2023

WslLogs-2023-01-06_13-32-11.zip
Logs of executable WORKING when running from WSL -> Powershell -> Powershell -> .exe

i.e. the failed log in the previous post WslLogs-2023-01-06_13-31-44.zip is:
wsl$> powershell.exe -c ConfigCmd.exe
Program 'ConfigCmd.exe' failed to run: Incorrect functionAt line:1 char:1

Whereas the working logs here are when I run:
wsl$> powershell.exe -c powershell.exe -c ConfigCmd.exe

@0anton
Copy link
Author

0anton commented Jan 6, 2023

See logs provided by @Rack1600. I can also generate mine, if needed...

@ghost ghost removed the needs-author-feedback label Jan 6, 2023
@0anton
Copy link
Author

0anton commented Jan 30, 2023

It looks like there is still no solution nor a proper workaround?

I've same behavior on Linux 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux on the client running Windows 11 22H2.

@alastairtree
Copy link

Seems to affect all windows executables saved into WSL fileshare and being run from powershell.exe (or pwsh.exe) which was launched from WSL.

My workaround was to uninstall the store version of WSL, and then the previous version of WSL was restored which still worked.

@0anton
Copy link
Author

0anton commented Feb 16, 2023

Also cmd.exe is not able launch anything from WSL. Uninstalling on Windows 11 is not possible, because it comes initially with the buggy versions (at least recent, fresh installs). It's a pity, that since creation, nobody from maintainers even dare to validate the problem...

@0anton
Copy link
Author

0anton commented Mar 6, 2023

This is is the same to all issues reporting unusual slowness of WSL2 starting Windows executables from WSL file system.

References

  1. Windows .exe execution is very slow when .exe is in WSL filesystem #8943
  2. https://superuser.com/questions/1762576/why-are-exe-very-slow-when-run-from-wsl2-filesystem

This is a nice and clean minimal repro suggested in [2]:

Executable started from Windows share takes nothing to start:

d057039:~$ time /mnt/c/Windows/system32/whoami.exe
global\d057039

real    0m0.089s
user    0m0.003s
sys     0m0.000s

Same executable started from WSL2 filesystems takes 1m45sec to run (sic!)

d057039:~$ cp /mnt/c/Windows/system32/whoami.exe .
d057039:~$ time ./whoami.exe
global\d057039

real    1m45.172s
user    0m0.003s
sys     0m0.000s

Bug is confirmed in kernels:

Linux w-B0ZXM03 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux w-B0ZXM03 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

As of now, latest WSL2 kernel is not fixed.

@marqueurs404
Copy link

Are there any updates on this issue? It still hasn't been fixed it seems.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

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

6 participants