Opticos / OpenInWSL-Source

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

Unable to get file association working #15

Open balaji-dutt opened 1 year ago

balaji-dutt commented 1 year ago

Hi,

I'm trying to open .org mode files using programs installed in WSL2 on Windows 10. I have tried this with both emacs and then for debugging with gedit but this does not seem to work. I have also tried switching the Graphical Backend between GWSL and wslg but there's no change.

Here is what I'm doing:

Version Info Ubuntu 22.04 running in WSL2/Windows 10 Open in WSL: 1.7 MSIX GWSL: 1.4.5 (Store)
Pololot64 commented 1 year ago

What happens if you run the commands mentioned in the logs directly eg emacs28 '/path/to/projects/hobbies.org'

Does anything run? Is an xserver or window server running correctly? This is a prerequisite

balaji-dutt commented 1 year ago

What happens if you run the commands mentioned in the logs directly eg emacs28 '/path/to/projects/hobbies.org'

This works correctly if I run the command from a WSL2 terminal - see screenshots below: WindowsTerminal_eVV0OgamO7 msrdc_RjvGSKrIk3

Does anything run? Is an xserver or window server running correctly? This is a prerequisite

I have setup Open in WSL to use wslg. I have tested opening an .org file with "Open in WSL" while having a WSL2 terminal open but that does not seem to make a difference. GWSL was throwing some errors so I wasn't able to try that option. I tried to open an .org file with VcXsrv and "Open in WSL" set to use "Other X Server" running but that did not work either.

Pololot64 commented 1 year ago

Does any other file type work?

balaji-dutt commented 1 year ago

Does any other file type work?

Things seem to be getting worse :-(.

I tried to set "Open in WSL" as the default program for .patch first and then for a dummy extension .ext and then set gedit as the associated program for both extensions in "Open in WSL". I created test.ext using the following command $ echo "foo" > test.ext.

For both .patch and .ext I'm seeing the following error:

2023-04-08 12:52:44,936 - OpenInWSL 1.7 MSIX - ERROR - Cannot Open extension error
Traceback (most recent call last):
  File "main.py", line 2272, in <module>
  File "main.py", line 515, in path_converter
IndexError: string index out of range
2023-04-08 12:53:14,075 - OpenInWSL 1.7 MSIX - ERROR - Cannot Open extension error
Traceback (most recent call last):
  File "main.py", line 2272, in <module>
  File "main.py", line 515, in path_converter
IndexError: string index out of range
2023-04-08 12:55:39,588 - OpenInWSL 1.7 MSIX - ERROR - Cannot Open extension error
Traceback (most recent call last):
  File "main.py", line 2272, in <module>
  File "main.py", line 515, in path_converter
IndexError: string index out of range

I tried to uninstall & reinstall Open in WSL via MS-Store but that does not seem to help as the settings/logs etc seem to persist between uninstalls.

Running gedit test.ext or gedit file.patch in a WSL2 terminal opens the file in gedit correctly.

Pololot64 commented 1 year ago

Ok we are getting somewhere. There is probably an issue with openinwsl parsing the windows path. Could you post the path to the file censoring only the words but not the structure (eg spaces, slashes, drive, punctuation)?

balaji-dutt commented 1 year ago

Ok we are getting somewhere. There is probably an issue with openinwsl parsing the windows path. Could you post the path to the file censoring only the words but not the structure (eg spaces, slashes, drive, punctuation)?

Apologies I realized later that the string index out of range error was due to my error. I was trying to open a file in the path \\wsl.localhost\Ubuntu-22.04\home\balaji\src\test.ext.

However I do have some good news!

I copied the file test.ext to the path C:\batch\test.ext and when I double clicked on the file in this path, it opened correctly in gedit. I also tested .org files by copying hobbies.org to C:\batch\hobbies.org and that worked perfectly with emacs28.

2023-04-09 16:24:50,826 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: gedit /mnt/c/batch/test.ext
2023-04-09 16:28:04,428 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: emacs28 /mnt/c/batch/hobbies.org

So indeed it appears that there's an issue with parsing the windows path in openinwsl.

Here is a lightly censored path to the original location of the hobbies.org file: /mnt/c/balaji/xxxxxxx/notes & projects/projects/hobbies.org. As before this fails without any real error in the logs, in fact it looks identical to the logs printed when I successfully opened the file from the path C:\batch\hobbies.org

2023-04-09 16:31:05,413 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: emacs28 '/mnt/c/balaji/xxxxxxx/notes & projects/projects/hobbies.org'
balaji-dutt commented 1 year ago

Hi @Pololot64 I was wondering if you had any suggestions / updates on this issue?

Pololot64 commented 1 year ago

Not yet. I have been doing exams. Well, I am a little confused about what the problem still is. I see that when the path is in Windows, it works properly. Is it only breaking when you use wsl paths like \wsl.localhost ?

balaji-dutt commented 1 year ago

Apologies if I've been unclear before. I will try and re-explain my current status:

Pololot64 commented 1 year ago

I see. In that case my second theory is that it is the "&" symbol in the path. When I convert the path to a Linux path and pass it through windows to Linux, it is parsed so many times that it is impossible to escape all special characters.

balaji-dutt commented 1 year ago

I see. In that case my second theory is that it is the "&" symbol in the path

Is that something that can be supported through an enhancement to "OpenIn WSL"?

Pololot64 commented 1 year ago

It would probably be possible to make a fix that fixes this special case but it would probably not scale well..

balaji-dutt commented 1 year ago

Ah I see. Well this is pretty disappointing news ☹️

Pololot64 commented 1 year ago

Again however, if this is extremely important feel free to email me and I can try to build you a version that fixes this. Also, theoretically when I am done with school I can make it try to escape everything but that will be hard to predict and plan for.

balaji-dutt commented 1 year ago

Again however, if this is extremely important feel free to email me and I can try to build you a version that fixes this. Also, theoretically when I am done with school I can make it try to escape everything but that will be hard to predict and plan for.

Hi @Pololot64 I have emailed you on your opticosstudios address on this.

Pololot64 commented 1 year ago

I'll get back to you