Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get file association working #15

Open
balaji-dutt opened this issue Apr 7, 2023 · 16 comments
Open

Unable to get file association working #15

balaji-dutt opened this issue Apr 7, 2023 · 16 comments

Comments

@balaji-dutt
Copy link

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:

  • Set file association for .org in OpeninWSL to gedit:
    image

  • Set file association for .org file in Windows Explorer to "OpeninWSL"
    image

  • Double click on a file hobbies.org in Windows Explorer.

  • What I expect to see

    • A gedit window will open with the file.
  • What happens instead:

    • I see the popup animation showing ".org >>> gedit" but nothing happens afterwards.
  • Logs:

2023-04-07 11:43:12,112 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: emacs28 '/path/to/projects/hobbies.org'
2023-04-07 11:43:56,570 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: emacs28 '/path/to/projects/hobbies.org'
2023-04-07 11:44:45,612 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: gedit --new-window '/path/to/projects/hobbies.org'
2023-04-07 11:46:10,243 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: gedit '/path/to/projects/hobbies.org'
2023-04-07 11:51:14,586 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: gedit '/path/to/projects/hobbies.org'
Version Info Ubuntu 22.04 running in WSL2/Windows 10 Open in WSL: 1.7 MSIX GWSL: 1.4.5 (Store)
@Pololot64
Copy link
Member

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
Copy link
Author

balaji-dutt commented Apr 8, 2023

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
Copy link
Member

Does any other file type work?

@balaji-dutt
Copy link
Author

balaji-dutt commented Apr 8, 2023

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
Copy link
Member

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
Copy link
Author

balaji-dutt commented Apr 9, 2023

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
Copy link
Author

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

@Pololot64
Copy link
Member

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
Copy link
Author

balaji-dutt commented Apr 20, 2023

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

  • I'm trying to open the file c:\balaji\xxxxxxx\notes & projects\projects\hobbies.org from Windows Explorer by double-clicking on the file.

    • .org files are set to open with OpenIn WSL in Windows.
    • In OpenIn WSL, .org files are configured to open with emacs
  • When I double-click the file c:\balaji\xxxxxxx\notes & projects\projects\hobbies.org, I see the ".org >>>>" pop-up in Windows, but the file does not open.

    • The only message in the OpenIn WSL log file is as follows:
    2023-04-09 16:31:05,413 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: emacs28 '/mnt/c/balaji/xxxxxxx/notes & projects/projects/hobbies.org'
    
  • If I copy the file c:\balaji\xxxxxxx\notes & projects\projects\hobbies.org to a different path with no spaces in the path, for example, c:\batch\hobbies.org, an emacs window does appear with the file open as expected.

    • The message in the log file is as follows:
    2023-04-09 16:28:04,428 - OpenInWSL 1.7 MSIX - INFO - RUN TEST: emacs28 /mnt/c/batch/hobbies.org
    
    • In other words, the messages in the log file are identical whether the program appears with the file open or nothing happens at all.
  • The only time I saw an actual error message was when I tried to open a file from \\wsl.localhost\Ubuntu-22.04\home\balaji\src\test.ext in Windows Explorer. I'm not sure that this type of UNC path is supported and hence would believe this particular error is not relevant to the problem mentioned above.

@Pololot64
Copy link
Member

Pololot64 commented Apr 20, 2023

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
Copy link
Author

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
Copy link
Member

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

@balaji-dutt
Copy link
Author

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

@Pololot64
Copy link
Member

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
Copy link
Author

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
Copy link
Member

I'll get back to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants