Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to launch default browser on WSL #1005

Closed
dhirschfeld opened this issue Dec 21, 2022 · 7 comments
Closed

Unable to launch default browser on WSL #1005

dhirschfeld opened this issue Dec 21, 2022 · 7 comments

Comments

@dhirschfeld
Copy link

I just upgraded my WSL and it seems to have affected my GCM install. When I click on the link in the modal dialog to open the devicecode page I'm now seeing the below error:

Unhandled exception. System.Exception: Failed to locate a utility to launch the default web browser.
   at GitCredentialManager.BrowserUtils.OpenDefaultBrowser(IEnvironment environment, Uri uri)
   at GitCredentialManager.BrowserUtils.OpenDefaultBrowser(IEnvironment environment, String url)
   at GitHub.UI.ViewModels.DeviceCodeViewModel.OpenVerificationUrl()
   at GitCredentialManager.UI.RelayCommand.Execute(Object parameter)
   at Avalonia.Controls.Button.OnClick() in /_/src/Avalonia.Controls/Button.cs:line 323
   at Avalonia.Controls.Button.OnPointerReleased(PointerReleasedEventArgs e) in /_/src/Avalonia.Controls/Button.cs:line 364
   at Avalonia.Input.InputElement.<>c.<.cctor>b__32_9(InputElement x, PointerReleasedEventArgs e) in /_/src/Avalonia.Input/InputElement.cs:line 223
   at Avalonia.Interactivity.RoutedEvent.<>c__DisplayClass23_0.<AddClassHandler>b__0(ValueTuple`2 args) in /_/src/Avalonia.Interactivity/RoutedEvent.cs:line 94
   at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in /_/Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs:line 67
   at System.Reactive.ObserverBase`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 36
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 145
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 148
   at Avalonia.Interactivity.EventRoute.RaiseEvent(IInteractive source, RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 79
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/Interactive.cs:line 123
   at Avalonia.Input.MouseDevice.MouseUp(IMouseDevice device, UInt64 timestamp, IInputRoot root, Point p, PointerPointProperties props, KeyModifiers inputModifiers) in /_/src/Avalonia.Input/MouseDevice.cs:line 313
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawPointerEventArgs e) in /_/src/Avalonia.Input/MouseDevice.cs:line 179
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawInputEventArgs e) in /_/src/Avalonia.Input/MouseDevice.cs:line 90
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in /_/src/Avalonia.Input/InputManager.cs:line 35
   at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e) in /_/src/Avalonia.Controls/TopLevel.cs:line 508
   at Avalonia.X11.X11Window.<.ctor>b__26_0(RawInputEventArgs e) in /_/src/Avalonia.X11/X11Window.cs:line 187
   at Avalonia.RawEventGrouper.DispatchFromQueue() in /_/src/Shared/RawEventGrouping.cs:line 54
   at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run() in /_/src/Avalonia.Base/Threading/JobRunner.cs:line 181
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in /_/src/Avalonia.Base/Threading/JobRunner.cs:line 37
   at Avalonia.X11.X11PlatformThreading.HandleX11(CancellationToken cancellationToken) in /_/src/Avalonia.X11/X11PlatformThreading.cs:line 169
   at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken) in /_/src/Avalonia.X11/X11PlatformThreading.cs:line 245
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 65
   at Avalonia.Controls.DesktopApplicationExtensions.Run(Application app, CancellationToken token) in /_/src/Avalonia.Controls/DesktopApplicationExtensions.cs:line 57
   at GitCredentialManager.UI.AvaloniaUi.<>c__DisplayClass6_1.<ShowWindowAsync>b__1()
   at GitCredentialManager.UI.Dispatcher.DispatcherJob.Execute()
   at GitCredentialManager.UI.Dispatcher.DispatcherJobQueue.Run()
   at GitCredentialManager.UI.Dispatcher.Run()
   at GitHub.UI.Program.Main(String[] args)
fatal: User canceled device code authentication
remote: Repository not found.
fatal: repository 'https://github.com/sede-x/SEAu_TnS_QuantDev.git/' not found
@dhirschfeld
Copy link
Author

I was able to resolve this issue by installing wslu which provides the wslview utility on Ubuntu:

sudo apt install wslu

@dhirschfeld
Copy link
Author

I just opened this issue for reference, in case it helps anyone else.

Since there's nothing to action here, I'll go ahead and close this.

@dscho
Copy link
Collaborator

dscho commented Dec 21, 2022

For me, xdg-open https://github.com/ works when called from inside WSL. And that is what GCM tries first. Does that command not work for you before you install wslu (which I have not installed, but I may have some dotfile like ~/.mailcap that makes this work)?

@dscho
Copy link
Collaborator

dscho commented Dec 21, 2022

I guess xdg-open does not necessarily work by default...

We could try to add a fall-back to do something like detecting the presence of the WSL_INTEROP environment variable (as a tell-tale that we're running inside the Windows Subsystem for Linux), and in that case detect whether we find powershell.exe in the PATH, and if that is the case, launch powershell.exe /c start <url>.

@dhirschfeld
Copy link
Author

For me, in my WSL:

❯ xdg-open https://github.com
Command 'xdg-open' not found, but can be installed with:
sudo apt install xdg-utils

@dhirschfeld
Copy link
Author

It might be sufficient to put a bit more context in the error message:
https://github.com/GitCredentialManager/git-credential-manager/blob/21b1c388eac50910d84fbe0ca73b4164bab0b906/src/shared/Core/BrowserUtils.cs#L61-L64

I had to search the source to find out about wslview which I'd never heard of before. Once I found that, installing wslu was straightforward.

Something like the below would provide a more actionable error message:

Failed to locate a utility to launch the default web browser.
Please install one of `{"xdg-open", "gnome-open", "kfmclient", "wslview"}`

@ghost
Copy link

ghost commented Nov 11, 2024

is it possible to simply display the link if one is logged in via ssh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants