{"record":{"id":"5cb8b719dfa6a7d4","repo":"can1357/oh-my-pi","slug":"cannot-determine-a-browser-platform-for-this-host","errorCode":null,"errorMessage":"Cannot determine a browser platform for this host","messagePattern":"Cannot determine a browser platform for this host","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/utils/src/browsers.ts","lineNumber":167,"sourceCode":"}\n\n/** Return the Chrome-for-Testing archive URL for a browser build. */\nexport function getDownloadUrl(\n\tbrowser: Browser,\n\tplatform: BrowserPlatform,\n\tbuildId: string,\n\tbaseUrl = CHROME_FOR_TESTING_BASE_URL,\n): URL {\n\tif (browser !== Browser.CHROME) throw new Error(`Unsupported browser download: ${browser}`);\n\tconst archivePlatform = chromeArchivePlatform(platform);\n\tconst root = baseUrl.replace(/\\/$/, \"\");\n\treturn new URL(`${root}/${buildId}/${archivePlatform}/chrome-${archivePlatform}.zip`);\n}\n\n/** Compute the executable path in Puppeteer's cache layout. */\nexport function computeExecutablePath(options: ComputeExecutablePathOptions): string {\n\tconst platform = options.platform ?? detectBrowserPlatform();\n\tif (!platform) throw new Error(\"Cannot determine a browser platform for this host\");\n\tif (options.browser !== Browser.CHROME) throw new Error(`Unsupported browser executable: ${options.browser}`);\n\tconst installDir = installationDir(options.cacheDir, options.browser, platform, options.buildId);\n\tswitch (platform) {\n\t\tcase BrowserPlatform.LINUX:\n\t\tcase BrowserPlatform.LINUX_ARM:\n\t\t\treturn path.join(installDir, \"chrome-linux64\", \"chrome\");\n\t\tcase BrowserPlatform.MAC:\n\t\t\treturn path.join(\n\t\t\t\tinstallDir,\n\t\t\t\t\"chrome-mac-x64\",\n\t\t\t\t\"Google Chrome for Testing.app\",\n\t\t\t\t\"Contents\",\n\t\t\t\t\"MacOS\",\n\t\t\t\t\"Google Chrome for Testing\",\n\t\t\t);\n\t\tcase BrowserPlatform.MAC_ARM:\n\t\t\treturn path.join(\n\t\t\t\tinstallDir,","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/browsers.ts#L149-L185","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Pass options.platform explicitly (e.g. BrowserPlatform.LINUX64 equivalent such as BrowserPlatform.LINUX) instead of relying on host detection.","Map your host manually: detect OS via process.platform and arch via process.arch, then choose the closest BrowserPlatform.","Run only on the supported matrix (Linux x64/arm, macOS x64/arm, Windows x64).","Check detectBrowserPlatform() yourself beforehand and fail with a clearer message."],"exampleFix":"// before\nconst p = computeExecutablePath({ browser: Browser.CHROME, buildId, cacheDir }); // host detection failed\n// after\nimport { detectBrowserPlatform } from './browsers';\nconst platform = detectBrowserPlatform() ?? (process.platform === 'linux' && process.arch === 'x64' ? BrowserPlatform.LINUX : undefined);\nif (!platform) throw new Error(`Unsupported host ${process.platform}/${process.arch}`);\nconst p = computeExecutablePath({ browser: Browser.CHROME, buildId, cacheDir, platform });","handlingStrategy":"fallback","validationCode":"import { detectBrowserPlatform, BrowserPlatform } from './browsers';\nconst SUPPORTED = new Set(Object.values(BrowserPlatform));\nconst detected = detectBrowserPlatform();\nif (!detected) {\n  console.warn(`Unrecognized host ${process.platform}/${process.arch}; supply an explicit platform`);\n}","typeGuard":"function platformIsKnown(p: ReturnType<typeof detectBrowserPlatform>): p is BrowserPlatform {\n  return p !== undefined;\n}","tryCatchPattern":"try {\n  const p = computeExecutablePath({ browser, buildId, cacheDir });\n} catch (err) {\n  if (err instanceof Error && err.message === 'Cannot determine a browser platform for this host') {\n    // ask user for --platform or fall back to a documented default\n  } else throw err;\n}","preventionTips":["Always pass options.platform explicitly in non-standard environments (containers, BSDs).","Fail fast at startup on unsupported platform/arch combinations.","Keep a mapping table for your deployment matrix (linux x64/arm, mac x64/arm, win x64)."],"tags":["platform-detection","environment","browser-download"],"backgroundTag":"unsupported-host-platform","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}