Improve error handling when unable to open browser
Closed this issue · 5 comments
When using WSL Ubuntu-24.04, the program exits with only this printed
2024/08/17 00:07:42 exit status 3
I was incredibly confused since I've used git-credential-auth with WSL Ubuntu (no versioning) just fine before. Turns out WSL Ubuntu-24.04 does not have wslu
pre-installed and thus xdg-open
cannot open the authentication link in the Windows host's browser.
Potential Solutions
- Replace error passthrough with more descriptive message
- Suggest user to try configuring
-device
flag if they are using GitHub or GitLab?- Alternatively, automatically fall back to device authentication instead?
- Detect if user is running in WSL using
systemd-detect-virt
and suggest them to installwslu
?
I'd be happy to sign the CLA and open a pull request for this!
Can you reproduce this with the latest version? I can't.
I did some digging and I figured out that xdg-open
actually isn't included by default, so LookPath
fails and the browser never attempts to open. However, xdg-open
is installed as a dependency when you use the Ubuntu package repository with sudo apt install git-credentials-oauth
.
Here's a reproduction using the latest release.
On Windows:
wsl --install --distribution Ubuntu-24.04
On WSL:
sudo apt update
sudo apt install -y xdg-utils # !! This is what will cause the behavior !!
curl -Ls https://github.com/hickford/git-credential-oauth/releases/download/v0.13.2/git-credential-oauth_0.13.2_linux_amd64.tar.gz \
| sudo tar -xzvC /usr/bin git-credential-oauth
sudo chmod +x /usr/bin/git-credential-oauth
git-credential-oauth configure
git clone https://github.com/example/example # !! Errors here !!
Thanks for @mass8326
I met the same error.
For my messy Debian WSL, xdg-open
exists but there's no application to open links.
My solution is adding https://github.com/4U6U57/wsl-open to PATH as xdg-open
.
I met the same error.
on WSl Ubuntu-22.04.