doctor: warn when running browser is snap-confined#333
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
Linux Ubuntu/Lubuntu users typically have chromium and firefox installed as snaps. Snap confinement runs the browser in a restricted mount namespace that blocks binding to CDP port 9222 even with --no-sandbox, so browser-harness's auto-discovery fails silently or with "Connection Refused" -- exactly the failure the issue reporter (browser-use#191) hit on Lubuntu. Add _detect_snap_browser() that scans 'ps -A -o args=' on Linux for processes whose argv[0] starts with /snap/{chromium,firefox, google-chrome}/ and matches a Chromium-family basename. run_doctor emits a [WARN] line with the snap path and points at non-snap install options when the function returns a hit. Non-Linux platforms short-circuit to None. ps failures (binary missing, timeout, OSError) also return None -- the doctor degrades to the existing checks instead of failing. 8 new tests cover: non-Linux skip, ps failure skip, no-browser skip, snap chromium hit, snap firefox hit, non-browser snap ignored (vscode), non-snap chromium ignored (apt-installed), doctor emits the warning row, doctor skips the row when no snap detected. All 103 existing tests still pass. This is the smallest of the four "Suggestions for Improvement" in browser-use#191. The other three (headless bootstrap mode, python3-pip docs, _chrome_running portable-binary discovery) are larger and likely want maintainer scoping first per Alezander9's structured- timeline ask in the issue thread. Refs browser-use#191. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refs #191.
Linux Ubuntu/Lubuntu users typically have
chromiumandfirefoxinstalledas snaps. Snap confinement runs the browser in a restricted mount namespace
that blocks binding to CDP port 9222 even with
--no-sandbox, sobrowser-harness's auto-discovery fails silently or with "Connection
Refused" -- exactly the failure the reporter hit on Lubuntu.
This adds the smallest of the four "Suggestions for Improvement" in
the issue: a
[WARN]row in--doctorthat surfaces the snap browser pathand points at non-snap install options. Catching it here saves the user the
"why is CDP refusing the connection?" troubleshooting round-trip.
What this is NOT
Per @Alezander9's ask for a structured timeline before broader changes,
this PR deliberately stays narrow:
_chrome_running, no changes todaemon startup, no headless bootstrap mode, no
python3-pipdoc work.subprocess.check_output(['ps', '-A', '-o', ...])pattern_chrome_runningalready uses.None.Implementation
src/browser_harness/admin.py_detect_snap_browser()helper (~30 lines). One new[WARN]line inrun_doctor.tests/unit/test_admin.py_detect_snap_browserscansps -A -o args=on Linux for processes whoseargv[0] starts with
/snap/{chromium,firefox,google-chrome}/and whosebasename matches a Chromium-family browser. Returns the path on hit,
Noneotherwise.psfailures (binary missing, timeout, OSError) alsoreturn
None-- the doctor degrades to the existing checks instead offailing.
The doctor row is shown only when the function returns a hit:
Verification
8 new tests cover:
psfailure short-circuit/snap/chromium/...chromium hit/snap/firefox/...firefox hit/snap/code/...)/usr/bin/chromiumignoredrun_doctoremits the warning when a snap browser is detectedrun_doctorskips the row when no snap browser is detectedNotes
_detect_snap_browser(returns the path) instead of a bool sothe warning message can include the actual snap path -- helpful for the
"is this still my snap or a stale process?" debugging step.
bootstrap mode, python3-pip docs, portable-binary discovery in
_chrome_running) feel like they want a separate maintainer scope perthe structured-timeline ask in the thread. Happy to take any of them
in follow-up PRs once direction is clearer.
public API commitment.
Summary by cubic
Warns Linux users when a running browser is snap‑confined in
--doctor, to explain CDP attach failures on port 9222 and suggest non‑snap installs. Addresses #191 by showing the snap path and clear next steps._detect_snap_browser()that scansps -A -o args=for/snap/{chromium,firefox,google-chrome}/and returns the path on hit.--doctornow prints[WARN] snap-confined browser detected — <path>with guidance to install a non-snap Chrome/Chromium for reliable CDP.pserrors; no new dependencies. Tests cover detection and doctor output.Written for commit 91cbb95. Summary will update on new commits.