Opticos / OpenInWSL-Source

The actual code for OpenInWSL. And some prebuilt releases.
https://opticos.github.io/openinwsl
Other
101 stars 16 forks source link

OpenInWSL doesn't work for files on network drives. #6

Open HawkinsT opened 3 years ago

HawkinsT commented 3 years ago

As per the title, I've been unable to launch files in windows explorer with OpenInWSL if they're on a network driver. The popup at the top of the screen that OpenInWSL usually displays to indicate how the file is being opened fails to appear also. Creating a local copy of such a file, OpenInWSL will then work as expected.

Pololot64 commented 3 years ago

Can you upload the logs? ( remove any personal info first but it would be good to know the details about the path)

Pololot64 commented 3 years ago

Also is it the store of github version of openinwsl?

HawkinsT commented 3 years ago

I'm using the store version; I can try the github version in a bit. The network location was of the format \\192.168.1.1\homes\blah\blah\somefile.py. Here's the log file (sorry for not including it previously):

2021-09-14 09:48:34,446 - OpenInWSL 1.5 store - ERROR - Cannot Open extension error
Traceback (most recent call last):
  File "main.py", line 1972, in <module>
  File "main.py", line 517, in path_converter
IndexError: string index out of range
Pololot64 commented 3 years ago

I look into this too. Again I am super busy but I won't forget.

HawkinsT commented 3 years ago

Thanks. Looking into it, it seems that OpenInWSL may have to mount a network drive in the wsl instance in order to get this to work, but I don't know if this would be desirable default behaviour for everyone or not.

Looking into this did highlight an issue with OpenInWSL's more general file handling though. It makes a few assumptions that aren't always correct, meaning trying to launch a file from within a linux file system via windows (viz. via \\wsl$) won't work.

The issue's with the path_converter function in main.py. It can be fixed simply in pure python, but since wsl comes with the wslpath utility specifically for this reason perhaps using this would be the best approach as I'd expect it to handle more edge cases:

import subprocess

def path_converter(path):
    subprocess = subprocess.Popen(f"wsl wslpath -a \'{path}\'", shell=True, stdout=subprocess.PIPE)
    nix_path = subprocess.stdout.read().strip().decode('UTF-8')
    return nix_path

I'd submit a PR but am unable to properly test this in windows at present.

Pololot64 commented 3 years ago

Thanks for digging again :) Yep. I should rewrite this. Unfortunately the earliest I can release changes is in December.

HawkinsT commented 3 years ago

No problem. Thanks for all your hard work on this and GWSL. :)