DDEV-Local WSL2: How do I get xdg-open to open a browser on Windows from WSL2?

Viewed 2353

In my wsl2 installation the "ddev launch" command stopped working this week, because the xdg-open command didn't work anymore. Setting the $BROWSER variable to a specific browser didn't work as the standard installation path contains spaces and this breaks in xdg-open. Also it would break if I switch browsers or use a different standard browser.

/usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: lynks: not found
/usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening [...]
failed to run launch: no method available for opening [...]

1 Answers

In WSL2 I added the Browser variable to ~/.bashrc

export BROWSER="powershell.exe /C start"

This opens the standard browser under windows. An alternative way would be to use

export BROWSER="explorer.exe"

but this opens the adress twice in the browser.

Links to other resources:

Related