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
help command makes assumptions about PATH in WSL environment #5756
Comments
As far as I'm concerned, the ideal way for us to deal with WSL is to pretend it doesn't exist. To a certain degree if that doesn't work, the system has failed. So I'd very much like for us to be able to use some open tool, but that only really works if one is installed and working by default (that most likely rules out wsl-open). Otherwise we'd be better off using the full path.
Is that path guaranteed to be correct, though? |
I don't think so. Windows can be installed into a differently-named directory, or we may not even be on the C: disk. The right way to refer to the path would be |
@faho I think I agree with you in regards to how to handle the existence of "WSL" is to pretend it doesn't -- meaning that for the vast majority of things the user is going to do, being using a distribution via WSL or running it on the hardware directly doesn't make dramatic difference. My impression here, like the other issue I filed elsewhere, is that the software knowing it is operating within this "WSL" environment allows us to take certain short-cuts that in an out-of-the-box scenario, makes things more convenient/pleasant experience overall. @floam additionally your comment made me also realize I skipped over something else wrt the Also: I believe that the environment variables from windows shell environments (the equivalents), should be made available via the EDIT: sorry I went off on a thing talking about clipboards, but that isn't the issue here, trying to rewrite it now. This makes me think that the over-all best way is to just hand things directly over to |
Fish already respects $BROWSER here on other systems, so this would simply require not automatically using just cmd.exe on wsl. We also already have an One other question: If we can find e.g. (Also cmd.exe needs to be handled a bit differently) |
Oh, also: The way xdg-open is supposed to work is that that's the thing you're supposed to call, and it then calls the appropriate tool for the environment, e.g. gvfs-open on gnome or kde-open5 on kde. So what wsl-open should be is a backend for xdg-open, so that we still only need to know about xdg-open. Does it currently work that way? |
@faho yes, I believe that is the whole purpose of EDIT:
with it eventually opening the webpage in |
Okay, so that means we want xdg-open if wsl-open is installed but cmd.exe (or rather /mnt/c/.../cmd.exe) if it isn't. At which point we could just try wsl-open. If neither exist, there isn't really anything we can do automatically so those users will just have to set $BROWSER. |
I think WSLENV actually is supposed to be empty by default. It looks like you need to set it up manually from the windows side to expose stuff into the Linux environment. It has modifiers for stuff like colon-separating path lists. |
Old: https://docs.microsoft.com/en-us/windows/wsl/interop Also, I published a utility for opening files/urls/folders/apps from within WSL or cmd.exe: https://github.com/neosmart/open Since it is compiled to |
This is not currently true for https://github.com/fish-shell/fish-shell/blob/master/share/functions/help.fish#L68-L74 # On OS X, we go through open by default
if test (uname) = Darwin
if type -q open
set fish_browser open
set need_trampoline 1
end
end That check needs to be |
Okay, now it's true. |
So, how about this check then: # If the OS appears to be Windows (graphical), try to use cygstart
if type -q cygstart
set fish_browser cygstart
# If xdg-open is available, just use that
# but only if an X session is running
else if type -q xdg-open; and set -q -x DISPLAY
set fish_browser xdg-open
end
# `command -s` also works on paths. It'll print the path again if it's an executable
if set -l cmd (command -s cmd.exe /mnt/c/Windows/System32/cmd.exe)
set fish_browser $cmd[1]
end
if type -q wsl-open
set fish_browser wsl-open
end
# "command" only because we define a function that might not have a backend.
# (Also TODO think about adding these as backends)
if command -sq open
set fish_browser open
end The idea being that the last of cygstart, xdg-open, cmd.exe, wsl-open, open wins. So we e.g. use cmd.exe even if xdg-open is installed because it might not be usable without wsl-open. Then we remove the special wsl check, and it's all nice and os-agnostic. |
Sorry, am i missing something here? -- I thought we recognized the fact the the prefix of |
It's a heuristic, it doesn't have to be perfect. We try cmd.exe, both via $PATH and via /mnt/c/..., but we also try wsl-open and open. If any one of them exists we've won. And if none of them do the user will just have to set $fish_help_browser.
Or just set $fish_help_browser. |
oh, oops, I didn't connect that part to it. Thanks for the info, and what seems to be a quick fix! |
We now try cmd.exe via $PATH and via a common location, wsl-open, and an open command. Fixes fish-shell#5756. [ci skip]
@samdmarshall: Can you confirm that #5759 works for you? |
@faho I just built fish locally (your branch) and that doesn't work for me. The command
which causes an error for me ( |
Ah krampus. I forgot that this is Debian, which ships a thing called "open", only it's a symlink to "openvt" (see #5091, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732796). Okay, we need to put open < xdg-open. |
Some systems like Debian have "open" as a symlink to "openvt" (for... historical reasons). See fish-shell#5756. [ci skip]
We now try cmd.exe via $PATH and via a common location, wsl-open, and an open command. Fixes fish-shell#5756. [ci skip]
Some systems like Debian have "open" as a symlink to "openvt" (for... historical reasons). See #5756. [ci skip]
We now try cmd.exe via $PATH and via a common location, wsl-open, and an open command. Fixes #5756. [ci skip]
Thanks for the super quick turn-around on this, and thank you (again) for all your work as maintainers!! |
I've encountered a problem with the code in
../share/fish/functions/help.fish
that has variable behavior based on user's/etc/wsl.conf
file. Here is what mine looks like:And the important bit here is the last option in this file (
appendWindowsPath = false
), means that I don't have the%PATH%
variable from the windows environment appended to my path in this flavor of Linux I am running (Ubuntu 16.04). I've documented this in another, similar, issue where code added that makes the assumption that this setting is always set totrue
(the default) and cannot find the windows executable that it needs to function.This configuration value has been available as of build 17743, release notes for more info. This seems like a very simple fix of:
cmd.exe
(/mnt/c/Windows/System32/cmd.exe
) to avoid having to figure out if thePATH
variable has the right directories added to it-OR-
open
/xdg-open
/wsl-open
/alternatives/etc.fish, version 3.0.2
uname --all
):Linux 4.4.0-17758-Microsoft #1-Microsoft Fri Sep 07 15:36:00 PST 2018 x86_64 GNU/Linux
TERM
:xterm-256color
The text was updated successfully, but these errors were encountered: