{"record":{"id":"7899e26a26863d72","repo":"iOfficeAI/OfficeCLI","slug":"no-screenshot-backend","errorCode":"no_screenshot_backend","errorMessage":"No headless browser available. Install Chrome/Edge/Chromium or Firefox, or `pip install playwright && playwright install chromium`. Last error: {r.Error}","messagePattern":"No headless browser available\\. Install Chrome/Edge/Chromium or Firefox, or `pip install playwright && playwright install chromium`\\. Last error: (.+?)","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.View.cs","lineNumber":472,"sourceCode":"                    var tmpHtml = Path.Combine(Path.GetTempPath(), $\"officecli_preview_{Path.GetFileNameWithoutExtension(file.Name)}_{DateTime.Now:HHmmss}_{Guid.NewGuid():N}.html\");\n                    File.WriteAllText(tmpHtml, html!);\n                    var r = clipArg != null\n                        ? OfficeCli.Core.HtmlScreenshot.CaptureClipped(tmpHtml, pngPath,\n                            OfficeCli.Core.HtmlScreenshot.ResolveClipDataPaths(clipArg))\n                        : OfficeCli.Core.HtmlScreenshot.Capture(tmpHtml, pngPath, screenshotWidth, screenshotHeight);\n                    try { File.Delete(tmpHtml); } catch { /* ignore */ }\n                    if (!r.Ok && r.Error == \"clip_target_not_found\")\n                    {\n                        throw new OfficeCli.Core.CliException(\n                            $\"--range target '{clipArg}' matched no rendered element.\")\n                        {\n                            Code = \"range_target_not_found\",\n                            Suggestion = \"Use a data-path the HTML preview emits (xlsx: 'Sheet1!A1:C3' within the sheet's used area; pptx: '/slide[N]/shape[K]'; docx: '/body/table[N]' or '/body/p[N]'). `query` lists element paths.\",\n                        };\n                    }\n                    if (!r.Ok)\n                    {\n                        throw new OfficeCli.Core.CliException(\n                            \"No headless browser available. Install Chrome/Edge/Chromium or Firefox, or `pip install playwright && playwright install chromium`.\"\n                            + (r.Error != null ? $\" Last error: {r.Error}\" : \"\"))\n                        { Code = \"no_screenshot_backend\" };\n                    }\n                }\n                Console.WriteLine(Path.GetFullPath(pngPath));\n                if (handler is OfficeCli.Handlers.PowerPointHandler pptCount)\n                    Console.Error.WriteLine($\"[pages] total={pptCount.GetSlideCount()}\");\n                if (browser)\n                {\n                    try\n                    {\n                        var psi = new System.Diagnostics.ProcessStartInfo(pngPath) { UseShellExecute = true };\n                        System.Diagnostics.Process.Start(psi);\n                    }\n                    catch { /* silently ignore if image viewer can't be opened */ }\n                }\n                return 0;","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.View.cs#L454-L490","documentation":"The HTML-fallback rasterizer needs a headless browser. When HtmlScreenshot.Capture/CaptureClipped returns Ok=false with an error other than clip_target_not_found, it means the browser discovery/launch itself failed — no Chrome/Edge/Chromium/Firefox binary found and Playwright not installed, or the browser crashed. The Last error detail is appended so the underlying failure (binary not found, sandbox error, etc.) is visible.","triggerScenarios":"Any screenshot/preview that falls through to the HTML path (native unavailable, --render html, or html-only format) on a machine with zero installed browsers and no Playwright runtime; or a browser binary present but failing to launch (missing libs, sandbox/permissions, headless flag unsupported in an old version).","commonSituations":"Minimal Linux server/container with no browser; PATH missing the browser; Chrome present but libnss/libatk absent; Playwright installed but `playwright install chromium` not run; snap-confined environment blocking browser launch.","solutions":["Install a headless browser: Chrome, Edge, Chromium, or Firefox on the PATH","Or `pip install playwright && playwright install chromium`","On Linux, install browser runtime libs (libnss3, libatk1.0, libxkbcommon0, libgbm1, etc.) or use Playwright which bundles deps","Read the appended `Last error:` to pinpoint the exact launch failure and address it"],"exampleFix":"// before: no browser installed, screenshot fails\n// after\npip install playwright && playwright install chromium\nofficecli view --mode screenshot deck.pptx","handlingStrategy":"fallback","validationCode":"// Ensure a headless browser exists before any HTML-path screenshot.\nbool HasBrowser() =>\n    OfficeCli.Core.HtmlScreenshot.ProbeBrowsers().Any(); // or check common binaries\nif (!HasBrowser())\n{\n    // install a browser or playwright; otherwise native-only formats will fail\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    // invoke view --mode screenshot file (HTML fallback path)\n}\ncatch (OfficeCli.Core.CliException ex) when (ex.Code == \"no_screenshot_backend\")\n{\n    // install a browser: Chrome/Edge/Chromium/Firefox, or\n    // `pip install playwright && playwright install chromium`, then retry\n    Console.Error.WriteLine(ex.Message);\n}","preventionTips":["Install Chrome/Edge/Chromium or Firefox on every host that runs screenshots","On Linux also install browser runtime libs, or use Playwright which bundles them","Run `playwright install chromium` after installing Playwright","Read the appended `Last error:` to diagnose launch failures"],"tags":["screenshot","browser","environment","playwright","html"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}