diff --git a/CHANGELOG.md b/CHANGELOG.md index feda4015934..10b169e0fb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Fixed an issue where `firebase` would error out instead of displaying help text. - Fixed an issue where `firebase init genkit` would error on Windows machines. - Fixed an issue where emulator returned error when emulating alerts functions written in python (#8019) +- Better error message for emulator binary architecture incompatibility on MacOS (#7995). - Deprecated `emulators.apphosting.startCommandOverride`. Please use `emulators.apphosting.startCommand` instead. - Updated `superstatic` to `9.1.0` in package.json. - Updated the Firebase Data Connect local toolkit to v1.7.4, which includes a fix for an issue that caused duplicate installations of the Firebase JS SDK. (#8028) diff --git a/src/emulator/dataconnectEmulator.ts b/src/emulator/dataconnectEmulator.ts index 8a8a0b2abfb..a1e83910bc8 100644 --- a/src/emulator/dataconnectEmulator.ts +++ b/src/emulator/dataconnectEmulator.ts @@ -6,7 +6,13 @@ import * as path from "path"; import { dataConnectLocalConnString } from "../api"; import { Constants } from "./constants"; -import { getPID, start, stop, downloadIfNecessary } from "./downloadableEmulators"; +import { + getPID, + start, + stop, + downloadIfNecessary, + isIncomaptibleArchError, +} from "./downloadableEmulators"; import { EmulatorInfo, EmulatorInstance, Emulators, ListenSpec } from "./types"; import { FirebaseError } from "../error"; import { EmulatorLogger } from "./emulatorLogger"; @@ -83,7 +89,6 @@ export class DataConnectEmulator implements EmulatorInstance { } catch (err: any) { this.logger.log("DEBUG", `'fdc build' failed with error: ${err.message}`); } - await start(Emulators.DATACONNECT, { auto_download: this.args.auto_download, listen: listenSpecsToString(this.args.listen), @@ -91,6 +96,7 @@ export class DataConnectEmulator implements EmulatorInstance { enable_output_schema_extensions: this.args.enable_output_schema_extensions, enable_output_generated_sdk: this.args.enable_output_generated_sdk, }); + this.usingExistingEmulator = false; if (this.args.autoconnectToPostgres) { const info = await load(this.args.projectId, this.args.config, this.args.configDir); @@ -211,7 +217,13 @@ export class DataConnectEmulator implements EmulatorInstance { cmd.push("--watch"); } const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" }); - + if (isIncomaptibleArchError(res.error)) { + throw new FirebaseError( + `Unknown system error when running the Data Connect toolkit. ` + + `You may be able to fix this by installing Rosetta: ` + + `softwareupdate --install-rosetta`, + ); + } logger.info(res.stderr); if (res.error) { throw new FirebaseError(`Error starting up Data Connect generate: ${res.error.message}`, { @@ -231,6 +243,13 @@ export class DataConnectEmulator implements EmulatorInstance { const cmd = ["--logtostderr", "-v=2", "build", `--config_dir=${args.configDir}`]; const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" }); + if (isIncomaptibleArchError(res.error)) { + throw new FirebaseError( + `Unkown system error when running the Data Connect toolkit. ` + + `You may be able to fix this by installing Rosetta: ` + + `softwareupdate --install-rosetta`, + ); + } if (res.error) { throw new FirebaseError(`Error starting up Data Connect build: ${res.error.message}`, { original: res.error, diff --git a/src/emulator/downloadableEmulators.ts b/src/emulator/downloadableEmulators.ts index 04f7b6e1e26..fe14ec717a9 100755 --- a/src/emulator/downloadableEmulators.ts +++ b/src/emulator/downloadableEmulators.ts @@ -468,6 +468,14 @@ async function _runBinary( emulator.name, `Could not spawn child process for emulator, check that java is installed and on your $PATH.`, ); + } else if (isIncomaptibleArchError(e)) { + logger.logLabeled( + "WARN", + emulator.name, + `Unknown system error when starting emulator binary. ` + + `You may be able to fix this by installing Rosetta: ` + + `softwareupdate --install-rosetta`, + ); } _fatal(emulator.name, e); } @@ -645,3 +653,12 @@ export async function start( ); return _runBinary(emulator, command, extraEnv); } + +export function isIncomaptibleArchError(err: unknown): boolean { + const hasMessage = (e: any): e is { message: string } => !!e.message; + return ( + hasMessage(err) && + /Unknown system error/.test(err.message ?? "") && + process.platform === "darwin" + ); +}