{"record":{"id":"86bf097fe767f29c","repo":"mislav/hub","slug":"please-set-browser-to-a-web-launcher","errorCode":null,"errorMessage":"Please set $BROWSER to a web launcher","messagePattern":"Please set \\$BROWSER to a web launcher","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"utils/utils.go","lineNumber":39,"sourceCode":"\t\tui.Errorln(err)\n\t\tos.Exit(1)\n\t}\n}\n\nfunc ConcatPaths(paths ...string) string {\n\treturn strings.Join(paths, \"/\")\n}\n\nfunc BrowserLauncher() ([]string, error) {\n\tbrowser := os.Getenv(\"BROWSER\")\n\tif browser == \"\" {\n\t\tbrowser = searchBrowserLauncher(runtime.GOOS)\n\t} else {\n\t\tbrowser = os.ExpandEnv(browser)\n\t}\n\n\tif browser == \"\" {\n\t\treturn nil, errors.New(\"Please set $BROWSER to a web launcher\")\n\t}\n\n\treturn shellquote.Split(browser)\n}\n\nfunc searchBrowserLauncher(goos string) (browser string) {\n\tswitch goos {\n\tcase \"darwin\":\n\t\tbrowser = \"open\"\n\tcase \"windows\":\n\t\tbrowser = \"cmd /c start\"\n\tdefault:\n\t\tcandidates := []string{\"xdg-open\", \"cygstart\", \"x-www-browser\", \"firefox\",\n\t\t\t\"opera\", \"mozilla\", \"netscape\"}\n\t\tfor _, b := range candidates {\n\t\t\tpath, err := exec.LookPath(b)\n\t\t\tif err == nil {\n\t\t\t\tbrowser = path","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/utils/utils.go#L21-L57","documentation":"hub's BrowserLauncher resolves which command opens a web page: it uses the BROWSER env var (after env expansion) or falls back to searchBrowserLauncher for the OS. If the resolved browser string is empty (BROWSER unset/empty and no OS default found), it returns this error and the caller (printBrowseOrCopy) falls back to copying the URL instead.","triggerScenarios":"Calling anything that opens a browser (`hub browse`) on an OS where searchBrowserLauncher finds nothing (e.g. an unsupported/uncommon OS) while $BROWSER is unset or empty after expansion.","commonSituations":"Running hub inside a container/SSH session without a desktop environment; using an exotic OS where hub has no built-in launcher detection; BROWSER set to empty string; BROWSER containing only whitespace after expansion.","solutions":["Set the BROWSER environment variable to a launcher command, e.g. `export BROWSER=open` (macOS), `xdg-open` (Linux), or a full browser path.","Use a full path if the browser isn't on PATH: export BROWSER=\"/usr/bin/firefox\".","Rely on the fallback: hub copies the URL to the clipboard when this error occurs, so paste it into a browser manually."],"exampleFix":"// before\n$ hub browse\nPlease set $BROWSER to a web launcher\n// after\n$ export BROWSER=xdg-open\n$ hub browse","handlingStrategy":"validation","validationCode":"if [ -z \"$BROWSER\" ] && ! command -v xdg-open >/dev/null 2>&1; then\n  export BROWSER=xdg-open   # or 'open' on macOS\nfi","typeGuard":null,"tryCatchPattern":"// hub itself falls back to copying the URL; in scripts:\nif hub browse 2>&1 | grep -q 'BROWSER'; then\n  echo \"URL copied to clipboard; open manually\"\nfi","preventionTips":["Set BROWSER in your shell profile (xdg-open / open / sensible-browser).","In containers/SSH, prefer `hub browse --copy` style workflows or expect clipboard fallback.","Verify with `hub browse` once after environment setup."],"tags":["environment","browser","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}