browsh-org/browsh · critical

Error reading Windows registry: %w

Error message

Error reading Windows registry: %w

What it means

getFirefoxPath looks up the installed Firefox executable under HKLM\Software\Mozilla\<flavor>\<versionString>\Main and reads PathToExe. If OpenKey fails (key or version subkey missing, or 32/64-bit view mismatch) browsh calls Shutdown, terminating with this wrapped error. It means browsh could not find the registry entry it uses to locate Firefox on Windows.

Source

Thrown at interfacer/src/browsh/firefox_windows.go:23

import (
	"fmt"
	"log/slog"
	"strings"

	"github.com/go-errors/errors"
	"golang.org/x/sys/windows/registry"
)

func getFirefoxPath() string {
	versionString := getWindowsFirefoxVersionString()
	flavor := getFirefoxFlavor()

	k, err := registry.OpenKey(
		registry.LOCAL_MACHINE,
		`Software\Mozilla\`+flavor+`\`+versionString+`\Main`,
		registry.QUERY_VALUE)
	if err != nil {
		Shutdown(fmt.Errorf("Error reading Windows registry: %w", err))
	}
	defer k.Close()

	path, _, err := k.GetStringValue("PathToExe")
	if err != nil {
		Shutdown(fmt.Errorf("Error reading Windows registry: %w", err))
	}

	return path
}

func getWindowsFirefoxVersionString() string {
	flavor := getFirefoxFlavor()

	k, err := registry.OpenKey(
		registry.LOCAL_MACHINE,
		`Software\Mozilla\`+flavor,
		registry.QUERY_VALUE)

View on GitHub (pinned to 499ef386d4)

Solutions

  1. Verify Firefox is installed machine-wide by checking HKLM\Software\Mozilla in regedit.
  2. Install the official Firefox build so the Main key with PathToExe exists.
  3. Use a flavor/version that matches the installed registry key names.
  4. Run browsh elevated (if the key requires higher read access) or run a 64-bit-matching build.
Defensive patterns

Strategy: fallback

Validate before calling

// PowerShell check before running browsh
Get-ItemProperty 'HKLM:\Software\Mozilla\Firefox\*\Main' -Name PathToExe -ErrorAction SilentlyContinue

Prevention

When it happens

Trigger: registry.OpenKey on LOCAL_MACHINE for `Software\Mozilla\<flavor>\<versionString>\Main` returns an error: the exact version subkey does not exist, Firefox was installed per-user (under HKCU) instead of machine-wide, or the key is not visible to the current registry view.

Common situations: Firefox not installed at all; installed via a per-user installer (no HKLM entry); multiple Firefox versions installed and the computed versionString subkey differs from the actual key name; 32-bit browsh running on 64-bit Windows without WOW64 redirection handling.

Related errors


AI-assisted analysis of browsh-org/browsh@499ef386d4 (2026-09-02). Data as JSON: /api/errors/d534faa2b85fdeb9. Report an issue: GitHub.