can1357/oh-my-pi · error · Error

Cannot determine a browser platform for this host

Error message

Cannot determine a browser platform for this host

What it means

computeExecutablePath needs a BrowserPlatform to build the Puppeteer cache-layout path; if none was supplied in options.platform and detectBrowserPlatform() cannot map the current host (OS/arch) to a known platform, this Error is thrown. It signals an unrecognized or unsupported host environment rather than a bad argument.

Solutions

  1. Pass options.platform explicitly (e.g. BrowserPlatform.LINUX64 equivalent such as BrowserPlatform.LINUX) instead of relying on host detection.
  2. Map your host manually: detect OS via process.platform and arch via process.arch, then choose the closest BrowserPlatform.
  3. Run only on the supported matrix (Linux x64/arm, macOS x64/arm, Windows x64).
  4. Check detectBrowserPlatform() yourself beforehand and fail with a clearer message.

Example fix

// before
const p = computeExecutablePath({ browser: Browser.CHROME, buildId, cacheDir }); // host detection failed
// after
import { detectBrowserPlatform } from './browsers';
const platform = detectBrowserPlatform() ?? (process.platform === 'linux' && process.arch === 'x64' ? BrowserPlatform.LINUX : undefined);
if (!platform) throw new Error(`Unsupported host ${process.platform}/${process.arch}`);
const p = computeExecutablePath({ browser: Browser.CHROME, buildId, cacheDir, platform });
Defensive patterns

Strategy: fallback

Validate before calling

import { detectBrowserPlatform, BrowserPlatform } from './browsers';
const SUPPORTED = new Set(Object.values(BrowserPlatform));
const detected = detectBrowserPlatform();
if (!detected) {
  console.warn(`Unrecognized host ${process.platform}/${process.arch}; supply an explicit platform`);
}

Type guard

function platformIsKnown(p: ReturnType<typeof detectBrowserPlatform>): p is BrowserPlatform {
  return p !== undefined;
}

Try / catch

try {
  const p = computeExecutablePath({ browser, buildId, cacheDir });
} catch (err) {
  if (err instanceof Error && err.message === 'Cannot determine a browser platform for this host') {
    // ask user for --platform or fall back to a documented default
  } else throw err;
}

Prevention

When it happens

Trigger: Calling computeExecutablePath({ browser, buildId, cacheDir }) without options.platform on a host where detectBrowserPlatform() returns undefined — an OS/arch combination not covered by the LINUX/LINUX_ARM/MAC/MAC_ARM/WIN32/WIN64 mapping (e.g. freebsd, linux-riscv, win-arm).

Common situations: Running on FreeBSD, Alpine-on-unusual-arch, WSL quirks, or ARM Windows where process.platform/process.arch fall outside the supported matrix; embedding in a sandbox with an unexpected platform string.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/5cb8b719dfa6a7d4. Report an issue: GitHub.

Appendix: source

Thrown at packages/utils/src/browsers.ts:167

}

/** Return the Chrome-for-Testing archive URL for a browser build. */
export function getDownloadUrl(
	browser: Browser,
	platform: BrowserPlatform,
	buildId: string,
	baseUrl = CHROME_FOR_TESTING_BASE_URL,
): URL {
	if (browser !== Browser.CHROME) throw new Error(`Unsupported browser download: ${browser}`);
	const archivePlatform = chromeArchivePlatform(platform);
	const root = baseUrl.replace(/\/$/, "");
	return new URL(`${root}/${buildId}/${archivePlatform}/chrome-${archivePlatform}.zip`);
}

/** Compute the executable path in Puppeteer's cache layout. */
export function computeExecutablePath(options: ComputeExecutablePathOptions): string {
	const platform = options.platform ?? detectBrowserPlatform();
	if (!platform) throw new Error("Cannot determine a browser platform for this host");
	if (options.browser !== Browser.CHROME) throw new Error(`Unsupported browser executable: ${options.browser}`);
	const installDir = installationDir(options.cacheDir, options.browser, platform, options.buildId);
	switch (platform) {
		case BrowserPlatform.LINUX:
		case BrowserPlatform.LINUX_ARM:
			return path.join(installDir, "chrome-linux64", "chrome");
		case BrowserPlatform.MAC:
			return path.join(
				installDir,
				"chrome-mac-x64",
				"Google Chrome for Testing.app",
				"Contents",
				"MacOS",
				"Google Chrome for Testing",
			);
		case BrowserPlatform.MAC_ARM:
			return path.join(
				installDir,

View on GitHub (pinned to 9690622007)