[GH-ISSUE #12] Some windows executables missing makes failures not graceful #11

Closed
opened 2026-03-04 12:23:48 +03:00 by kerem · 6 comments
Owner

Originally created by @ringtailedfox on GitHub (Jun 9, 2020).
Original GitHub issue: https://github.com/cascadium/wsl-windows-toolbar-launcher/issues/12

The script installs just fine, but if i try to run it with Python 3.8.3 x64 for Windows, I get this odd error:

C:>wsl-windows-toolbar
Traceback (most recent call last):
File "C:\Python38-x64\lib\runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Python38-x64\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Python38-x64\Scripts\wsl-windows-toolbar.exe_main
.py", line 4, in
File "C:\Python38-x64\lib\site-packages\wsl_windows_toolbar\wsl_windows_toolbar.py", line 8, in
import magic
File "C:\Python38-x64\lib\site-packages\magic.py", line 179, in
libmagic = ctypes.CDLL(dll)
File "C:\Python38-x64\lib\ctypes_init
.py", line 373, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

Originally created by @ringtailedfox on GitHub (Jun 9, 2020). Original GitHub issue: https://github.com/cascadium/wsl-windows-toolbar-launcher/issues/12 The script installs just fine, but if i try to run it with Python 3.8.3 x64 for Windows, I get this odd error: C:\>wsl-windows-toolbar Traceback (most recent call last): File "C:\Python38-x64\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Python38-x64\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Python38-x64\Scripts\wsl-windows-toolbar.exe\__main__.py", line 4, in <module> File "C:\Python38-x64\lib\site-packages\wsl_windows_toolbar\wsl_windows_toolbar.py", line 8, in <module> import magic File "C:\Python38-x64\lib\site-packages\magic.py", line 179, in <module> libmagic = ctypes.CDLL(dll) File "C:\Python38-x64\lib\ctypes\__init__.py", line 373, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 is not a valid Win32 application
kerem closed this issue 2026-03-04 12:23:49 +03:00
Author
Owner

@fquinner commented on GitHub (Jun 10, 2020):

Hi there! The script needs to run within the wsl environment itself rather than on windows. I'll try and and add something to script to avoid what you did and make it a little more intuitive.

<!-- gh-comment-id:641750353 --> @fquinner commented on GitHub (Jun 10, 2020): Hi there! The script needs to run within the wsl environment itself rather than on windows. I'll try and and add something to script to avoid what you did and make it a little more intuitive.
Author
Owner

@ringtailedfox commented on GitHub (Jun 11, 2020):

Hi there! The script needs to run within the wsl environment itself rather than on windows. I'll try and and add something to script to avoid what you did and make it a little more intuitive.

ahhh, okay that makes a lot more sense! I figured either I did something wrong, or was misunderstanding something... okay. thanks for the rapid response! :D

<!-- gh-comment-id:642344118 --> @ringtailedfox commented on GitHub (Jun 11, 2020): > Hi there! The script needs to run within the wsl environment itself rather than on windows. I'll try and and add something to script to avoid what you did and make it a little more intuitive. ahhh, okay that makes a lot more sense! I figured either I did something wrong, or was misunderstanding something... okay. thanks for the rapid response! :D
Author
Owner

@fcjbispo commented on GitHub (Oct 29, 2020):

Hi there! The script needs to run within the wsl environment itself rather than on windows. I'll try and and add something to script to avoid what you did and make it a little more intuitive.

This is what happens if it is called insid wsl:
fcjbispo@RAGNAROK:/mnt/c/Users/fcjbispo$ wsl-windows-toolbar Traceback (most recent call last): File "/home/fcjbispo/.local/bin/wsl-windows-toolbar", line 5, in <module> from wsl_windows_toolbar.wsl_windows_toolbar import cli File "/home/fcjbispo/.local/lib/python3.8/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 26, in <module> WINDOWS_USERPROFILE = subprocess.check_output( File "/usr/lib/python3.8/subprocess.py", line 411, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.8/subprocess.py", line 489, in run with Popen(*popenargs, **kwargs) as process: File "/usr/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'cmd.exe'
What do you mean with: "The script needs to run within the wsl environment itself rather than on windows." ?

<!-- gh-comment-id:718974054 --> @fcjbispo commented on GitHub (Oct 29, 2020): > Hi there! The script needs to run within the wsl environment itself rather than on windows. I'll try and and add something to script to avoid what you did and make it a little more intuitive. This is what happens if it is called insid wsl: `fcjbispo@RAGNAROK:/mnt/c/Users/fcjbispo$ wsl-windows-toolbar Traceback (most recent call last): File "/home/fcjbispo/.local/bin/wsl-windows-toolbar", line 5, in <module> from wsl_windows_toolbar.wsl_windows_toolbar import cli File "/home/fcjbispo/.local/lib/python3.8/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 26, in <module> WINDOWS_USERPROFILE = subprocess.check_output( File "/usr/lib/python3.8/subprocess.py", line 411, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.8/subprocess.py", line 489, in run with Popen(*popenargs, **kwargs) as process: File "/usr/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'cmd.exe'` What do you mean with: "The script needs to run within the wsl environment itself rather than on windows." ?
Author
Owner

@fquinner commented on GitHub (Oct 29, 2020):

You'll need cmd.exe to be in your PATH too even when executing from within WSL :)

I mean it needs to be run within WSL bash. The originally reported issue was run from a windows shell.

<!-- gh-comment-id:718976840 --> @fquinner commented on GitHub (Oct 29, 2020): You'll need cmd.exe to be in your PATH too even when executing from within WSL :) I mean it needs to be run within WSL bash. The originally reported issue was run from a windows shell.
Author
Owner

@matthieudesprez commented on GitHub (Oct 31, 2020):

export PATH=$PATH:/mnt/c/Windows/System32:/mnt/c/Windows/System32/WindowsPowerShell/v1.0

In my case that did the trick, because the script also needs powershell.exe

<!-- gh-comment-id:719950148 --> @matthieudesprez commented on GitHub (Oct 31, 2020): ``` export PATH=$PATH:/mnt/c/Windows/System32:/mnt/c/Windows/System32/WindowsPowerShell/v1.0 ``` In my case that did the trick, because the script also needs powershell.exe
Author
Owner

@fquinner commented on GitHub (Nov 29, 2020):

These are now checked on startup and will fail gracefully of not present in 0.6.0

<!-- gh-comment-id:735433041 --> @fquinner commented on GitHub (Nov 29, 2020): These are now checked on startup and will fail gracefully of not present in 0.6.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/wsl-windows-toolbar-launcher#11
No description provided.