From c239d9edc72d85697b4875c98fff3ec592848082 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 19 Apr 2021 09:00:43 +0200 Subject: [PATCH] feat(launcher): fix installation error on Apple M1 chips (#7099) * feat(launcher): fix installation error on Apple M1 chips The previous logic assumed that an arm64 arch is only available in Linux. WIth Apple's arm64 M1 Chip this assumption isn't true anymore. Currently there are no official macOS arm64 chromium builds available, but we can make use of the excellent Rosetta feature in macOS which allows us to run x86 binaries on M1. Once native macOS arm64 Chromium builds are available we should switch to those. Issue: #6622 Co-authored-by: Mathias Bynens --- src/node/BrowserFetcher.ts | 5 ++++- src/node/Launcher.ts | 4 +++- src/node/install.ts | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/node/BrowserFetcher.ts b/src/node/BrowserFetcher.ts index 11e85bb6..c1792aa7 100644 --- a/src/node/BrowserFetcher.ts +++ b/src/node/BrowserFetcher.ts @@ -293,7 +293,10 @@ export class BrowserFetcher { if (await existsAsync(outputPath)) return this.revisionInfo(revision); if (!(await existsAsync(this._downloadsFolder))) await mkdirAsync(this._downloadsFolder); - if (os.arch() === 'arm64') { + + // Use Intel x86 builds on Apple M1 until native macOS arm64 + // Chromium builds are available. + if (os.platform() !== 'darwin' && os.arch() === 'arm64') { handleArm64(); return; } diff --git a/src/node/Launcher.ts b/src/node/Launcher.ts index 828b18c0..b116be45 100644 --- a/src/node/Launcher.ts +++ b/src/node/Launcher.ts @@ -105,7 +105,9 @@ class ChromeLauncher implements ProductLauncher { let chromeExecutable = executablePath; if (!executablePath) { - if (os.arch() === 'arm64') { + // Use Intel x86 builds on Apple M1 until native macOS arm64 + // Chromium builds are available. + if (os.platform() !== 'darwin' && os.arch() === 'arm64') { chromeExecutable = '/usr/bin/chromium-browser'; } else { const { missingText, executablePath } = resolveExecutablePath(this); diff --git a/src/node/install.ts b/src/node/install.ts index 41f2834d..bb44f4e2 100644 --- a/src/node/install.ts +++ b/src/node/install.ts @@ -90,7 +90,9 @@ export async function downloadBrowser() { if (NPM_NO_PROXY) process.env.NO_PROXY = NPM_NO_PROXY; function onSuccess(localRevisions: string[]): void { - if (os.arch() !== 'arm64') { + // Use Intel x86 builds on Apple M1 until native macOS arm64 + // Chromium builds are available. + if (os.platform() !== 'darwin' && os.arch() !== 'arm64') { logPolitely( `${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}` );