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 <mathias@qiwi.be>
This commit is contained in:
Marvin Hagemeister 2021-04-19 09:00:43 +02:00 committed by GitHub
parent a22aa5deac
commit c239d9edc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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}`
);