Panniantong/Agent-Reach · error · RuntimeError

Could not read {browser} cookies via rookiepy: {scrub_url_cr

Error message

Could not read {browser} cookies via rookiepy: {scrub_url_credentials(e)}
Make sure {browser} is closed and you have permission.

What it means

Raised by extract_all() in agent_reach/cookie_extract.py when the rookiepy backend throws while loading cookies for the requested browser. Any exception from browser_funcs[browser](domains) — locked SQLite cookie stores, permission errors, or rookiepy internals — is wrapped in this RuntimeError with the underlying message scrubbed of credentials. rookiepy is only used when no profile is selected.

Source

Thrown at agent_reach/cookie_extract.py:281

        # rookiepy returns list of dicts with name/value/domain/path keys
        try:
            browser_funcs = {
                "chrome": rookiepy.chrome,
                "firefox": rookiepy.firefox,
                "edge": rookiepy.edge,
                "brave": rookiepy.brave,
                "opera": rookiepy.opera,
            }
            raw_cookies = browser_funcs[browser](list(spec["domains"]))
            # Wrap into objects with .name, .value, .domain for compatibility
            class _Cookie:
                def __init__(self, d):
                    self.name = d.get("name", "")
                    self.value = d.get("value", "")
                    self.domain = d.get("domain", "")
            cookie_jar = [_Cookie(c) for c in raw_cookies]
        except Exception as e:
            raise RuntimeError(
                f"Could not read {browser} cookies via rookiepy: "
                f"{scrub_url_credentials(e)}\n"
                f"Make sure {browser} is closed and you have permission."
            )
    else:
        browser_funcs = {
            "chrome": browser_cookie3.chrome,
            "firefox": browser_cookie3.firefox,
            "edge": browser_cookie3.edge,
            "brave": browser_cookie3.brave,
            "opera": browser_cookie3.opera,
        }
        try:
            cookie_jar = []
            seen = set()
            for domain in spec["domains"]:
                kwargs = {"domain_name": domain}
                if cookie_file is not None:

View on GitHub (pinned to 93ae1d18c3)

Solutions

  1. Close the target browser completely (including background processes) and retry
  2. Verify the browser has been used and has a cookie store on this machine
  3. If it keeps failing, install browser-cookie3 and/or fall back to a manual Cookie-Editor export

Example fix

# before
cookies = extract_all(browser='chrome', platform='bilibili')  # RuntimeError while Chrome open

# after: ensure Chrome is closed first
import subprocess; subprocess.run(['pkill', '-f', 'Google Chrome'])
cookies = extract_all(browser='chrome', platform='bilibili')
Defensive patterns

Strategy: retry

Validate before calling

def browser_running(name: str) -> bool:
    out = subprocess.run(['pgrep', '-fl', {'chrome': 'Chrome', 'edge': 'msedge', 'brave': 'brave', 'opera': 'opera'}[name]], capture_output=True)
    return out.returncode == 0

Try / catch

for attempt in range(2):
    try:
        cookies = extract_all(browser='chrome', platform='bilibili')
        break
    except RuntimeError as e:
        if 'rookiepy' in str(e) and attempt == 0:
            close_browser('chrome'); continue
        raise

Prevention

When it happens

Trigger: extract_all(browser='chrome', platform='xueqiu') while Chrome is running (cookie DB locked), on Linux with an encrypted keyring rookiepy cannot unlock, or when the browser has never created a cookie store.

Common situations: Running extraction with the browser open; headless CI boxes with no Chrome profile ever initialized; snap-packaged Chromium storing cookies where rookiepy does not look.

Related errors


AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14). Data as JSON: /api/errors/9a64ca5320a6bec7. Report an issue: GitHub.