Some windows executables missing makes failures not graceful
ringtailedfox opened this issue · 6 comments
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
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.
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
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." ?
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.
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
These are now checked on startup and will fail gracefully of not present in 0.6.0