fix(browser): strip PYTHONPATH/PYTHONHOME from browser-use CLI subprocess env (salvage #83471) - #86371
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
૮ >ﻌ< ა ci reviewran on c1ed96f — fix(browser): strip PYTHONPATH/PYTHONHOME from browser-use C
|
…cess env The browser-use CLI runs under its own Python (uv tool / uvx), which can differ from Hermes's venv interpreter. PYTHONPATH/PYTHONHOME inherited from the agent process point at Hermes's venv site-packages, and a child interpreter honors them ahead of its own — so the CLI imported compiled C-extensions (pydantic_core) built for the wrong interpreter and crashed with ABI mismatch / ModuleNotFoundError (issues 83427, 84841, 86006, 86104; hits the desktop backend on py3.14 and any shell exporting PYTHONPATH). Strip both vars in _base_subprocess_env() — the CLI manages its own environment and never needs Hermes's import path. Salvaged from PR 83471 by Benjamin (@n1majne3), the earliest of two independent fixes (also PR 84022 by @jklance16, PYTHONPATH-only); regression test covers both vars and preserves unrelated env.
3f3be93 to
c1ed96f
Compare
Summary
browser_execno longer crashes with pydantic_core ABI mismatch /ModuleNotFoundErrorwhen the parent process carriesPYTHONPATH/PYTHONHOME— the browser-use CLI subprocess env now strips both, so the CLI's own interpreter resolves its own packages.Root cause: the CLI runs under its own Python (uv tool / uvx), but a child interpreter honors inherited
PYTHONPATH/PYTHONHOMEahead of its own site-packages — importing C-extensions built for Hermes's venv interpreter. Hit the desktop backend on py3.14 and any shell exportingPYTHONPATH.Fixes #83427, #84841, #86006, #86104.
Salvage of #83471 by @n1majne3 (earliest of two independent fixes; #84022 by @jklance16 covered PYTHONPATH only) — the contributor branch bundled unrelated desktop commits via a merge, so the browser hunk was surgically reapplied with authorship preserved.
Changes
tools/browser_use_cli.py:_base_subprocess_env()popsPYTHONPATHandPYTHONHOME.tests/tools/test_browser_use_cli.py: regression test — both vars stripped, unrelated env preserved (the test shape suggested in fix(browser): strip PYTHONPATH/PYTHONHOME from browser-use CLI subprocess env #83471's review).Validation
Infographic