xtekky/gpt4free · critical · RuntimeError

Google Chrome / Chromium / Edge executable not found.

Error message

Google Chrome / Chromium / Edge executable not found.

What it means

Raised in g4f/requests/cdp.py's shared-browser bootstrap (get_shared_browser_port flow) when no already-running CDP endpoint was found on the host and find_chrome_path() could not locate a Chrome, Chromium, or Edge binary in standard locations. The CDP client never launches its own bundled browser — it relies on a system-installed Chromium-family executable, so none found means automation cannot start.

Source

Thrown at g4f/requests/cdp.py:226

                # Browser died or became unreachable, clean up
                if _shared_browser_process:
                    try:
                        _shared_browser_process.terminate()
                    except Exception:
                        pass
                    _shared_browser_process = None
                _shared_browser_port = None

        # 2. Check if a browser is already running anywhere on the system with CDP remote debugging
        running_port = find_running_cdp_port(host)
        if running_port is not None:
            _shared_browser_port = running_port
            return _shared_browser_port

        # 3. Otherwise, launch a new shared Chromium process on a free port
        chrome_path = find_chrome_path()
        if not chrome_path:
            raise RuntimeError("Google Chrome / Chromium / Edge executable not found.")

        # Find a free port dynamically
        import socket

        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
            s.bind(("", 0))
            port = s.getsockname()[1]

        # Use standard user config directory for profile caching (like other g4f browsers)
        try:
            from platformdirs import user_config_dir

            user_data_dir = user_config_dir("g4f-cdp")
        except ImportError:
            import tempfile

            user_data_dir = os.path.join(
                tempfile.gettempdir(), "g4f_chrome_profile_cdp"

View on GitHub (pinned to 973504e177)

Solutions

  1. Install Google Chrome, Chromium, or Microsoft Edge on the host (e.g. apt-get install -y chromium on Debian/Ubuntu).
  2. If the browser is installed in a non-standard location, point g4f at it via its browser executable configuration (BrowserConfig/executable path settings) instead of relying on auto-detection.
  3. In Docker, add a browser layer, e.g. `FROM chromedp/headless-shell` style images or install chromium in the Dockerfile.
  4. Verify detection before running: check that `chromium --version` (or equivalent) works from the same environment.

Example fix

# Dockerfile before: FROM python:3.12-slim (no browser)
# after
FROM python:3.12-slim
RUN apt-get update && apt-get install -y chromium && rm -rf /var/lib/apt/lists/*
Defensive patterns

Strategy: validation

Validate before calling

import shutil

def has_chromium() -> bool:
    return any(shutil.which(b) for b in ("google-chrome", "google-chrome-stable", "chromium", "chromium-browser", "microsoft-edge"))

Try / catch

try:
    port = get_shared_browser_port()  # or CDPSession()/start()
except RuntimeError as e:
    if "executable not found" in str(e):
        raise SystemExit("Install Chrome/Chromium/Edge first")
    raise

Prevention

When it happens

Trigger: First use of CDPSession/SyncCDPSession on a machine (or container) with no Chrome/Chromium/Edge installed or installed in a non-standard path; headless servers and slim Docker images where no browser was ever added.

Common situations: Deploying to alpine/slim Docker images; macOS with Chrome only in a user profile that find_chrome_path does not scan; Linux servers where only firefox is present.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/924a1d290ca9c46a. Report an issue: GitHub.