DDEV in WSL2: How do I get `ddev launch` to open a browser on Windows? [closed]
Asked Answered
A

2

15

I'm using DDEV and in my wsl2 installation the ddev launch command stopped working this week, apparently 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<br />
/usr/bin/xdg-open: links2: not found<br />
/usr/bin/xdg-open: elinks: not found<br />
/usr/bin/xdg-open: links: not found<br />
/usr/bin/xdg-open: lynks: not found<br />
/usr/bin/xdg-open: w3m: not found<br />
xdg-open: no method available for opening [...]<br />
failed to run launch: no method available for opening [...]
Absenteeism answered 11/3, 2021 at 15:16 Comment(1)
Related issue: github.com/drud/ddev/issues/2877Haha
A
16

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:

Absenteeism answered 11/3, 2021 at 15:20 Comment(0)
I
7

Another way that might achieve what you're looking for is to install WSL (wsl utilities) using:

sudo apt install wslu

This will install wslview which will handle proper windows interactions via the WSL layer including the correct link opening behaviors with xdg-open, etc.

After installing, try rerunning your command.

Irrespirable answered 18/8, 2023 at 3:7 Comment(2)
this sounds like a great solution, unfortunately it does not work for me. I tried removing and reinstalling wslu. do I need to configure wslview in some way?Heathenry
If you want to use wslview to open instead of xdg-open you'll need to symlink or alias the two i.e sudo ln -s /usr/bin/wslview /usr/local/bin/xdg-openRecife

© 2022 - 2024 — McMap. All rights reserved.