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

add support for WSL #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

arminaaki
Copy link

This patch adds support for Windows Subsystem for Linux.

}

if wsl {
cmd := "cmd.exe"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux systems under WSL ship with a wslview utility available in PATH that can be used in place of xdg-open. Therefore, the fix for this would be to just add wslview as fallback to providers above; no detection necessary nor spawning cmd.exe.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback. I started a fresh install of Windows 10, and wslview doesn't seem to exist in Linux WSL2 installations by default. However, installing WSL utilities adds wslview and creates a symbolic link for x-www-browser, which resolves the original issue.

$ apt install wslu
Reading package lists... Done
....
update-alternatives: using /usr/bin/wslview to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/wslview to provide /usr/bin/www-browser (www-browser) in auto mode
$ ls -la /usr/bin/x-www-browser
lrwxrwxrwx 1 root root 31 Aug  7 00:20 /usr/bin/x-www-browser -> /etc/alternatives/x-www-browser

$ ls -la /etc/alternatives/x-www-browser
lrwxrwxrwx 1 root root 16 Aug  7 00:20 /etc/alternatives/x-www-browser -> /usr/bin/wslview

If the implementation above is an overhead to the package, I'm happy to close the PR in favor of having wslview utility as a required dependency in WSL installations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed dive. I see added value in your approach being compatible even if WSL utilities aren't installed, but I'm surprised that the cmd.exe approach works. Do Linux subsystems contain a cmd.exe in their PATH that, when executed, is connected to the host Windows system? Sorry, I'm not very experienced with WSL, and I don't have a Windows instance I can try on at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do believe that the providers approach should be tried before the isWSL block.

@yongzhang
Copy link

Will this feature to be continued?

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

Successfully merging this pull request may close these issues.

None yet

3 participants