Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/web2cli/auth/browser_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ def _is_missing_browser_error(exc: Exception) -> bool:
"executable doesn't exist" in text
or "chromium distribution 'chrome'" in text
or "cannot find chromium" in text
or "download new browsers" in text
or ("playwright install" in text and "chromium" in text)
)


def _install_chromium(status_cb: Callable[[str], None] | None) -> None:
_emit(status_cb, "Installing browser engine (one-time, ~50MB)...")
_emit(status_cb, "Installing browser engine (one-time, ~250MB)...")
_run_command([sys.executable, "-m", "playwright", "install", "chromium"])


Expand Down Expand Up @@ -783,7 +784,17 @@ def capture_auth_with_browser(
raise BrowserLoginCancelled("Login cancelled by user")
except Exception as e:
if _is_missing_browser_error(e):
_install_chromium(status_cb)
try:
_install_chromium(status_cb)
except Exception as install_error:
raise BrowserLoginError(
"Browser engine is missing and automatic install failed.\n"
"Try manual setup:\n"
f" {sys.executable} -m playwright install chromium\n"
"Then verify with:\n"
" web2cli doctor browser --deep\n"
f"Install error: {install_error}"
)
try:
return asyncio.run(
_capture_auth_once(
Expand Down