Skip to content

Support `gdk open` on Windows Subsystem for Linux

What does this merge request do and why?

Initial attempt to get gdk open to work on WSL. This is a first pass, happy to receive feedback. It calls Machine.wsl? the first call now which is slightly "intensive", but since it's cached I'm assuming it's OK. This sacrifice might be too expensive to support an advanced configuration.

References:

How to determine if WSL?

  1. https://github.com/microsoft/WSL/issues/4071#issuecomment-496737093
  2. https://superuser.com/a/1749811

caveat: pwsh.exe only is for PowerShell version 7 and above.

Most windows installations currently use PowerShell (powershell.exe version 5) by default, but in the future this will be more reliable. In the present this might not be very helpful.

https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3

(they can be installed alongside eachother)

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Be on Windows
  2. gdk start
  3. gdk open

On the main branch, this would yield:

[zarthus@windows ~/Dev/gitlab-development-kit] main ✔ $ gdk start
...

[zarthus@windows ~/Dev/gitlab-development-kit] main ✔ $ gdk open
sh: 1: xdg-open: not found

[zarthus@windows ~/Dev/gitlab-development-kit] main ✔ $ echo $?
127

On this feature branch, this would yield:

[zarthus@windows ~/Dev/gitlab-development-kit] jah/support-gdk-open-on-wsl ✔ $ gdk start
...

[zarthus@windows ~/Dev/gitlab-development-kit] jah/support-gdk-open-on-wsl ✔ $ gdk open

[zarthus@windows ~/Dev/gitlab-development-kit] jah/support-gdk-open-on-wsl ✔ $ echo $?
0
before after
image image

Alternative implementation:

https://github.com/cpbotha/xdg-open-wsl or adding some small script like

/usr/bin/xdg-open

pwsh.exe -Command Start-Process $@

Might work too.

We could add this to documentation.

Impacted categories

The following categories relate to this merge request:

Merge request checklist

  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise an issue to follow-up.
  • Documentation added/updated, if needed.
  • Announcement added, if change is notable.
  • gdk doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.
Edited by Jos Ahrens

Merge request reports