cpbotha / xdg-open-wsl

xdg-open replacement for WSL that opens files and links using Windows apps.
BSD 3-Clause "New" or "Revised" License
162 stars 12 forks source link

Error with FileNotFoundError: [Errno 2] No such file or directory: 'explorer.exe' #8

Closed Liampor closed 1 year ago

Liampor commented 1 year ago

I have installed xdg-open-wsl in my wsl1 successfully

Tried use follow command to open a pdf file xdg-open "/mnt/d/project/readme.pdf"

it returns

Traceback (most recent call last):
  File "/home/timo/.local/bin/xdg-open", line 8, in <module>
    sys.exit(main())
  File "/home/timo/.local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/timo/.local/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/timo/.local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/timo/.local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/timo/.local/lib/python3.9/site-packages/xdg_open_wsl/xdg_open_wsl.py", line 207, in main
    completed_process = subprocess.run(sp_run_arg)
  File "/home/timo/miniconda3/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/timo/miniconda3/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/timo/miniconda3/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'explorer.exe'

How could I solve it ? thanks

jonathanjameswatson commented 1 year ago

It seems to be this: https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#command-not-found-when-executing-windows-exe-in-linux

In my case, this was caused by appendWindowsPath = false in my /etc/wsl.conf, but the link gives other reasons why this could occur.

Liampor commented 1 year ago

@jonathanjameswatson Sorry for the late response, Yes I have set the appendWindowsPath = false, and this issue could be solved by adding the path in my .zshrc file

export PATH="/mnt/c/Windows:$PATH"