Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(browser): only a complete browser cache skips the Linux Chrome download; name a missing unzip

AdityaUmaled0f140880354
diff --git a/apps/docs/content/docs/self-hosting/deploy-vps.mdx b/apps/docs/content/docs/self-hosting/deploy-vps.mdx
index 8db7ecc40e..41b94bd3dd 100644
--- a/apps/docs/content/docs/self-hosting/deploy-vps.mdx
+++ b/apps/docs/content/docs/self-hosting/deploy-vps.mdx
@@ -169,9 +169,10 @@ npx --yes openmausbot browser install
The administrator's browser download is in a different home; it does not install
the service account's browser. Both commands must finish successfully. If the
-service account has no browser, `serve` downloads Chrome for Testing (about
-190 MB) into its data directory when it starts; the system
-libraries from the first command are still needed.
+service account has no browser and the built-in browser is on, `serve` on an
+x64 or arm64 server downloads Chrome for Testing (about 190 MB) into its data
+directory when it starts. That needs `unzip`, and the system libraries from the
+first command are still needed.
On Ubuntu 24.04, AppArmor may also require [administrator sandbox setup](#ubuntu-2404-browser-sandbox).
The one-click installer downloads the browser; it does not grant these OS permissions.
diff --git a/docs/browser-packaging.md b/docs/browser-packaging.md
index 01bd95e073..535819d00e 100644
--- a/docs/browser-packaging.md
+++ b/docs/browser-packaging.md
@@ -49,8 +49,10 @@ real Chrome whenever this machine has one, chosen once per machine
Servers and the Docker image name their browser with
`AGENT_BROWSER_EXECUTABLE_PATH` (the image's Chrome for Testing), or use the
-Chrome for Testing `agent-browser install` put in place; with neither, a
-server downloads its own as in step 2. `OMB_CHROME_PATH`
+Chrome for Testing `agent-browser install` put in place. A Linux server where
+agent-browser already finds a browser (Chrome, Chromium or Brave on `PATH`, or a
+complete Puppeteer or Playwright Chromium in their caches) keeps it; with none,
+it downloads its own as in step 2. `OMB_CHROME_PATH`
names one explicitly. An `OMB_AGENT_BROWSER_PATH` engine keeps its own choice
unless a Chrome is named too.
diff --git a/server/browser/chrome/install.ts b/server/browser/chrome/install.ts
index 8458b1282e..db04b60ec5 100644
--- a/server/browser/chrome/install.ts
+++ b/server/browser/chrome/install.ts
@@ -105,7 +105,10 @@ export const extractZip: Extract = (archive, directory) => new Promise((resolve,
? [win32.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe"), ["-xf", archive, "-C", directory]]
: ["unzip", ["-q", archive, "-d", directory]];
execFile(file, args, { timeout: EXTRACT_TIMEOUT_MS, windowsHide: true, maxBuffer: 16 * 1024 * 1024 }, (error) => {
- if (error) reject(new Error(`the Chrome archive could not be unpacked: ${error.message}`));
+ if (error) {
+ const noUnzip = file === "unzip" && (error as NodeJS.ErrnoException).code === "ENOENT";
+ reject(new Error(noUnzip ? "the Chrome archive could not be unpacked: unzip is not installed here (Debian/Ubuntu: sudo apt-get install unzip)" : `the Chrome archive could not be unpacked: ${error.message}`));
+ }
else resolve();
});
});
diff --git a/server/browser/chrome/resolve.test.ts b/server/browser/chrome/resolve.test.ts
index c7029fa390..8014ac3490 100644
--- a/server/browser/chrome/resolve.test.ts
+++ b/server/browser/chrome/resolve.test.ts
@@ -97,9 +97,12 @@ describe("which Chrome the bots' browser runs", () => {
const withPath = (files: string[], env: NodeJS.ProcessEnv = {}) => host("linux", files, { env: { PATH: "/usr/local/bin:/usr/bin", ...env } });
expect(resolveChromePlan(withPath(["/usr/bin/chromium"]), managed)).toEqual(found);
expect(resolveChromePlan(withPath(["/usr/local/bin/google-chrome-stable"]), managed)).toEqual(found);
- expect(resolveChromePlan(withPath(["/home/ada/.cache/puppeteer/chrome/linux-153.0.8010.47"]), managed)).toEqual(found);
- expect(resolveChromePlan(withPath(["/home/ada/.cache/ms-playwright/chromium-1200"]), managed)).toEqual(found);
- expect(resolveChromePlan(withPath(["/pw/chromium-1200"], { PLAYWRIGHT_BROWSERS_PATH: "/pw" }), managed)).toEqual(found);
+ expect(resolveChromePlan(withPath(["/home/ada/.cache/puppeteer/chrome/linux-153.0.8010.47/chrome-linux64/chrome"]), managed)).toEqual(found);
+ expect(resolveChromePlan(withPath(["/home/ada/.cache/ms-playwright/chromium-1200/chrome-linux/chrome"]), managed)).toEqual(found);
+ expect(resolveChromePlan(withPath(["/pw/chromium-1200/chrome-linux64/chrome"], { PLAYWRIGHT_BROWSERS_PATH: "/pw" }), managed)).toEqual(found);
+ // A cache entry without its browser executable is incomplete: the server still downloads.
+ expect(resolveChromePlan(withPath(["/home/ada/.cache/puppeteer/chrome/linux-153.0.8010.47/README"]), managed)).toMatchObject({ kind: "download" });
+ expect(resolveChromePlan(withPath(["/home/ada/.cache/ms-playwright/chromium-1200/INSTALLATION_COMPLETE"]), managed)).toMatchObject({ kind: "download" });
expect(resolveChromePlan(withPath(["/home/ada/.cache/ms-playwright/firefox-1500", "/opt/firefox/firefox"]), managed)).toMatchObject({ kind: "download" });
const downloaded = chromeForTestingExecutable("/data", chromeForTestingPin("linux", "arm64")!);
expect(resolveChromePlan(withPath(["/usr/bin/chromium", downloaded]), managed)).toMatchObject({ kind: "chrome", chrome: { source: "downloaded" } });
diff --git a/server/browser/chrome/resolve.ts b/server/browser/chrome/resolve.ts
index 59f3309883..14fcaef3ea 100644
--- a/server/browser/chrome/resolve.ts
+++ b/server/browser/chrome/resolve.ts
@@ -103,13 +103,18 @@ export function agentBrowserChrome(host: ChromeHost): string | null {
/** agent-browser's own search on Linux: these browsers on PATH, then Puppeteer's and Playwright's caches. */
const LINUX_ENGINE_BROWSERS = ["google-chrome", "google-chrome-stable", "google-chrome-unstable", "chromium", "chromium-browser", "brave-browser", "brave-browser-stable"];
+/** Where Puppeteer and Playwright unpack Chrome inside a cache entry; an entry without one is incomplete. */
+const LINUX_CACHE_EXECUTABLES = ["chrome-linux64/chrome", "chrome-linux/chrome"];
+
/** A Linux server where agent-browser already finds a browser keeps it rather than downloading another. */
export function engineFindsLinuxBrowser(host: ChromeHost): boolean {
const { join } = posix;
const onPath = (host.env.PATH ?? "").split(":").filter(Boolean);
if (onPath.some((directory) => LINUX_ENGINE_BROWSERS.some((name) => host.exists(join(directory, name))))) return true;
- if (host.list(join(host.env.PUPPETEER_CACHE_DIR || join(host.home, ".cache", "puppeteer"), "chrome")).length) return true;
- return host.list(host.env.PLAYWRIGHT_BROWSERS_PATH || join(host.home, ".cache", "ms-playwright")).some((name) => name.startsWith("chromium"));
+ const cached = (directory: string, prefix: string) => host.list(directory)
+ .some((name) => name.startsWith(prefix) && LINUX_CACHE_EXECUTABLES.some((executable) => host.exists(join(directory, name, executable))));
+ return cached(join(host.env.PUPPETEER_CACHE_DIR || join(host.home, ".cache", "puppeteer"), "chrome"), "linux")
+ || cached(host.env.PLAYWRIGHT_BROWSERS_PATH || join(host.home, ".cache", "ms-playwright"), "chromium-");
}
export function resolveChromePlan(host: ChromeHost, engine: ChromeEngine | null): ChromePlan {