{"record":{"id":"d1df42c8613844c1","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-locate-a-utility-to-launch-the-default-w","errorCode":null,"errorMessage":"Failed to locate a utility to launch the default web browser.","messagePattern":"Failed to locate a utility to launch the default web browser\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Core/Interop/Linux/LinuxSessionManager.cs","lineNumber":43,"sourceCode":"\n    protected override void OpenBrowserInternal(string url)\n    {\n        //\n        // On Linux, 'shell execute' utilities like xdg-open launch a process without\n        // detaching from the standard in/out descriptors. Some applications (like\n        // Chromium) write messages to stdout, which is currently hooked up and being\n        // consumed by Git, and cause errors.\n        //\n        // Sadly, the Framework does not allow us to redirect standard streams if we\n        // set ProcessStartInfo::UseShellExecute = true, so we must manually launch\n        // these utilities and redirect the standard streams manually.\n        //\n        // We try and use the same 'shell execute' utilities as the Framework does,\n        // searching for them in the same order until we find one.\n        //\n        if (!TryGetShellExecuteHandler(Environment, out string shellExecPath))\n        {\n            throw new Exception(\"Failed to locate a utility to launch the default web browser.\");\n        }\n\n        Trace.WriteLine($\"Opening browser using '{shellExecPath}: {url}\");\n\n        var psi = new ProcessStartInfo(shellExecPath, url)\n        {\n            RedirectStandardOutput = true,\n            // Ok to redirect stderr for non-git-related processes\n            RedirectStandardError = true\n        };\n\n        Process.Start(psi);\n    }\n\n    private bool GetWebBrowserAvailable()\n    {\n        // We need a shell execute handler to be able to launch to browser\n        if (!TryGetShellExecuteHandler(Environment, out _))","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Interop/Linux/LinuxSessionManager.cs#L25-L61","documentation":"OpenBrowserInternal searches the system for a known 'shell execute' utility (xdg-open and similar, in the same order as the .NET Framework) to launch a URL. If none of the candidate utilities exist on PATH it throws, because there is no way to open the default browser.","triggerScenarios":"Calling the session manager's OpenBrowser (OpenBrowserInternal) on a Linux system where no browser-launch helper (xdg-open, gnome-open, kde-open, wslview, etc.) is installed or on PATH.","commonSituations":"Minimal/headless Linux images (containers, servers, slim distros) that lack xdg-utils; broken PATH in the process environment; stripped-down chroot or WSL without wslview.","solutions":["Install xdg-utils (e.g. `apt-get install xdg-utils` or `dnf install xdg-utils`) so xdg-open exists on PATH","Verify PATH inside the process includes the directory containing xdg-open (`which xdg-open`)","Open the URL manually on a headless machine instead of calling the browser-open API","Set BROWSER env var and provide a wrapper script if using a custom launcher"],"exampleFix":"// before\nsessionManager.OpenBrowser(url); // throws on headless box\n// after\nif (TryFindOnPath(\"xdg-open\", out _)) sessionManager.OpenBrowser(url);\nelse Console.WriteLine($\"Open this URL manually: {url}\");","handlingStrategy":"fallback","validationCode":"static bool BrowserLauncherExists() =>\n    new[]{\"xdg-open\",\"gnome-open\",\"kde-open\",\"wslview\"}.Any(t =>\n        Environment.GetEnvironmentVariable(\"PATH\")!\n            .Split(':').Any(dir => File.Exists(Path.Combine(dir, t))));","typeGuard":"bool CanOpenBrowser() => TryGetShellExecuteHandler(out _);","tryCatchPattern":"try { sessionManager.OpenBrowser(url); }\ncatch (Exception ex) when (ex.Message.Contains(\"Failed to locate a utility\")) { Console.WriteLine($\"Open manually: {url}\"); }","preventionTips":["Install xdg-utils on Linux images used for development","Don't call browser-open APIs on headless servers; print the URL instead","Verify `which xdg-open` works inside containers before relying on it","Keep PATH unmodified when launching the library"],"tags":["linux","browser","dependency","environment"],"backgroundTag":"missing-dependency","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}