From a9395ddecc6b233c4c5d851e54f1bd504bb02a3c Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Tue, 7 Mar 2023 09:04:42 -0800 Subject: [PATCH] Use electron API to detect Rosetta --- ts/updater/common.ts | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/ts/updater/common.ts b/ts/updater/common.ts index 265bdcd95d..98bdb738f0 100644 --- a/ts/updater/common.ts +++ b/ts/updater/common.ts @@ -5,8 +5,6 @@ import { createWriteStream } from 'fs'; import { pathExists } from 'fs-extra'; import { readdir, stat, writeFile, mkdir } from 'fs/promises'; -import { promisify } from 'util'; -import { execFile } from 'child_process'; import { join, normalize, extname } from 'path'; import { tmpdir, release as osRelease } from 'os'; import { throttle } from 'lodash'; @@ -714,22 +712,12 @@ export abstract class Updater { return process.arch; } - try { - // We might be running under Rosetta - const flag = 'sysctl.proc_translated'; - const { stdout } = await promisify(execFile)('sysctl', ['-i', flag]); - - if (stdout.includes(`${flag}: 1`)) { - this.logger.info('updater: running under Rosetta'); - return 'arm64'; - } - } catch (error) { - this.logger.warn( - `updater: Rosetta detection failed with ${Errors.toLogFormat(error)}` - ); + if (app.runningUnderARM64Translation) { + this.logger.info('updater: running under arm64 translation'); + return 'arm64'; } - this.logger.info('updater: not running under Rosetta'); + this.logger.info('updater: not running under arm64 translation'); return process.arch; } }