Skip to content

Commit

Permalink
feat(launcher): fix installation error on Apple M1 chips (#7099)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
marvinhagemeister and mathiasbynens committed Apr 19, 2021
1 parent a22aa5d commit c239d9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/node/BrowserFetcher.ts
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/node/Launcher.ts
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/node/install.ts
Expand Up @@ -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}`
);
Expand Down

0 comments on commit c239d9e

Please sign in to comment.