Skip to content

Commit 7f1c599

Browse files
authored
Better error message when Rosetta is missing (#8030)
1 parent 9ad8df3 commit 7f1c599

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Fixed an issue where `firebase` would error out instead of displaying help text.
44
- Fixed an issue where `firebase init genkit` would error on Windows machines.
55
- Fixed an issue where emulator returned error when emulating alerts functions written in python (#8019)
6+
- Better error message for emulator binary architecture incompatibility on MacOS (#7995).
67
- Deprecated `emulators.apphosting.startCommandOverride`. Please use `emulators.apphosting.startCommand` instead.
78
- Updated `superstatic` to `9.1.0` in package.json.
89
- 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)

src/emulator/dataconnectEmulator.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import * as path from "path";
66

77
import { dataConnectLocalConnString } from "../api";
88
import { Constants } from "./constants";
9-
import { getPID, start, stop, downloadIfNecessary } from "./downloadableEmulators";
9+
import {
10+
getPID,
11+
start,
12+
stop,
13+
downloadIfNecessary,
14+
isIncomaptibleArchError,
15+
} from "./downloadableEmulators";
1016
import { EmulatorInfo, EmulatorInstance, Emulators, ListenSpec } from "./types";
1117
import { FirebaseError } from "../error";
1218
import { EmulatorLogger } from "./emulatorLogger";
@@ -83,14 +89,14 @@ export class DataConnectEmulator implements EmulatorInstance {
8389
} catch (err: any) {
8490
this.logger.log("DEBUG", `'fdc build' failed with error: ${err.message}`);
8591
}
86-
8792
await start(Emulators.DATACONNECT, {
8893
auto_download: this.args.auto_download,
8994
listen: listenSpecsToString(this.args.listen),
9095
config_dir: resolvedConfigDir,
9196
enable_output_schema_extensions: this.args.enable_output_schema_extensions,
9297
enable_output_generated_sdk: this.args.enable_output_generated_sdk,
9398
});
99+
94100
this.usingExistingEmulator = false;
95101
if (this.args.autoconnectToPostgres) {
96102
const info = await load(this.args.projectId, this.args.config, this.args.configDir);
@@ -211,7 +217,13 @@ export class DataConnectEmulator implements EmulatorInstance {
211217
cmd.push("--watch");
212218
}
213219
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
214-
220+
if (isIncomaptibleArchError(res.error)) {
221+
throw new FirebaseError(
222+
`Unknown system error when running the Data Connect toolkit. ` +
223+
`You may be able to fix this by installing Rosetta: ` +
224+
`softwareupdate --install-rosetta`,
225+
);
226+
}
215227
logger.info(res.stderr);
216228
if (res.error) {
217229
throw new FirebaseError(`Error starting up Data Connect generate: ${res.error.message}`, {
@@ -231,6 +243,13 @@ export class DataConnectEmulator implements EmulatorInstance {
231243
const cmd = ["--logtostderr", "-v=2", "build", `--config_dir=${args.configDir}`];
232244

233245
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
246+
if (isIncomaptibleArchError(res.error)) {
247+
throw new FirebaseError(
248+
`Unkown system error when running the Data Connect toolkit. ` +
249+
`You may be able to fix this by installing Rosetta: ` +
250+
`softwareupdate --install-rosetta`,
251+
);
252+
}
234253
if (res.error) {
235254
throw new FirebaseError(`Error starting up Data Connect build: ${res.error.message}`, {
236255
original: res.error,

src/emulator/downloadableEmulators.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,14 @@ async function _runBinary(
468468
emulator.name,
469469
`Could not spawn child process for emulator, check that java is installed and on your $PATH.`,
470470
);
471+
} else if (isIncomaptibleArchError(e)) {
472+
logger.logLabeled(
473+
"WARN",
474+
emulator.name,
475+
`Unknown system error when starting emulator binary. ` +
476+
`You may be able to fix this by installing Rosetta: ` +
477+
`softwareupdate --install-rosetta`,
478+
);
471479
}
472480
_fatal(emulator.name, e);
473481
}
@@ -645,3 +653,12 @@ export async function start(
645653
);
646654
return _runBinary(emulator, command, extraEnv);
647655
}
656+
657+
export function isIncomaptibleArchError(err: unknown): boolean {
658+
const hasMessage = (e: any): e is { message: string } => !!e.message;
659+
return (
660+
hasMessage(err) &&
661+
/Unknown system error/.test(err.message ?? "") &&
662+
process.platform === "darwin"
663+
);
664+
}

0 commit comments

Comments
 (0)