Closed rgwood closed 1 year ago
Sure thing, I've updated the PR so it will only attempt to run wslview when running in WSL.
I've looked into this space before and I believe the is-wsl
crate is the best way to do this check. It's maintained by Sean Larkinn at Microsoft; I have reviewed the crate's code (and contributed to it). The author is actively maintaining it (unlike the older wsl
crate). It caches the result with once_cell
so we'll only pay the cost once.
I ran cargo bloat
before+after this PR and it seems like it adds about 13KB to the open
executable on Linux:
Thanks a lot, especially for the due diligence!
I have additionally limited the is-wsl
dependency to be only for unix.
This PR fixes a bug I've been experiencing on WSL.
I have
gio
installed in my WSL environment because it comes bundled withglib
. Because of this,open-rs
attempts to usegio
and fails:To solve this, this PR just reorders the launchers used on unix so that
wslview
is attempted first. I think this is desirable behaviour because ifwslview
is present we're almost certainly in WSL.If you foresee any problems with this approach, I could rewrite this to check whether we're in WSL before attempting to use
wslview
.