Skip to content

Commit c55db3e

Browse files
aledog007Alessio Fanoclaude
authored
fix(server): Antigravity installs on Intel Macs (pingdotgg#30189)
Co-authored-by: Alessio Fano <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 291bcc3 commit c55db3e

2 files changed

Lines changed: 92 additions & 6 deletions

File tree

‎apps/server/src/provider/AntigravityInstallation.test.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import * as Scope from "effect/Scope";
1818
import * as Sink from "effect/Sink";
1919
import * as Stream from "effect/Stream";
2020
import { HttpClient, HttpClientResponse } from "effect/http";
21+
import * as ChildProcess from "effect/process/ChildProcess";
22+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
2123

2224
import * as AntigravityInstallation from "./AntigravityInstallation.ts";
2325
import { type AntigravityReleaseAsset } from "./antigravityRelease.ts";
@@ -121,6 +123,7 @@ interface HarnessOptions {
121123
readonly path?: string;
122124
readonly previous?: boolean;
123125
readonly fileSystem?: FileSystem.FileSystem;
126+
readonly spawner?: ChildProcessSpawner.ChildProcessSpawner["Service"];
124127
readonly validate?: AntigravityInstallation.AntigravityInstallationOptions["validate"];
125128
readonly useDefaultValidation?: boolean;
126129
}
@@ -175,6 +178,9 @@ const makeHarness = Effect.fn("test.makeAntigravityInstallation")(function* (
175178
),
176179
}),
177180
}).pipe(
181+
options.spawner
182+
? Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, options.spawner)
183+
: (effect) => effect,
178184
Effect.provideService(FileSystem.FileSystem, trackedFs),
179185
Effect.provideService(HostProcess.Platform, platform),
180186
Effect.provideService(HostProcess.Architecture, arch),
@@ -571,6 +577,58 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst
571577
}),
572578
);
573579

580+
it.effect("re-signs the Intel Mac runtime ad hoc and records the signed sizes", () =>
581+
Effect.gen(function* () {
582+
const fs = yield* FileSystem.FileSystem;
583+
const signed: Array<ReadonlyArray<string>> = [];
584+
const spawner = ChildProcessSpawner.make((command) =>
585+
Effect.gen(function* () {
586+
if (!ChildProcess.isStandardCommand(command))
587+
return yield* Effect.die("Unexpected spawn.");
588+
const args = command.args.map(String);
589+
signed.push([String(command.command), ...args]);
590+
// codesign rewrites the signature, which changes each file's size.
591+
for (const file of args.slice(3)) {
592+
yield* fs.writeFileString(file, "signature", { flag: "a" });
593+
}
594+
return ChildProcessSpawner.makeHandle({
595+
pid: ChildProcessSpawner.ProcessId(900_000_301),
596+
exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(0)),
597+
isRunning: Effect.succeed(false),
598+
kill: () => Effect.void,
599+
unref: Effect.succeed(Effect.void),
600+
stdin: Sink.drain,
601+
stdout: Stream.empty,
602+
stderr: Stream.empty,
603+
all: Stream.empty,
604+
getInputFd: () => Sink.drain,
605+
getOutputFd: () => Stream.empty,
606+
});
607+
}).pipe(Effect.orDie),
608+
);
609+
const { installation, validations } = yield* makeHarness({
610+
platform: "darwin",
611+
arch: "x64",
612+
spawner,
613+
});
614+
yield* installation.start;
615+
expect((yield* terminalState(installation)).phase).toBe("succeeded");
616+
const validated = validations[0]?.executable;
617+
expect(signed).toEqual([
618+
[
619+
"/usr/bin/codesign",
620+
"--force",
621+
"--sign",
622+
"-",
623+
validated?.executablePath,
624+
validated?.harnessPath,
625+
],
626+
]);
627+
const selected = yield* installation.resolve();
628+
expect(yield* fs.readFileString(selected.executablePath)).toBe(`${serverContents}signature`);
629+
}),
630+
);
631+
574632
// The mocked Linux PATH walk needs POSIX paths; Windows temp paths contain colons.
575633
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
576634
"honors explicit paths and reports invalid overrides without falling back",

‎apps/server/src/provider/AntigravityInstallation.ts‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import * as Semaphore from "effect/Semaphore";
2121
import * as Stream from "effect/Stream";
2222
import * as SubscriptionRef from "effect/SubscriptionRef";
2323
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
24+
import * as ChildProcess from "effect/process/ChildProcess";
2425
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
2526
import * as NodeCrypto from "node:crypto";
2627
import * as NodeFSP from "node:fs/promises";
@@ -642,15 +643,39 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
642643
}
643644
}).pipe(Effect.scoped);
644645
yield* fs.remove(archivePath);
646+
const executablePath = path.join(pairDirectory, asset.executable.name);
647+
const harnessPath = path.join(pairDirectory, asset.harness.name);
645648
if (platform !== "win32") {
646-
yield* fs.chmod(path.join(pairDirectory, asset.executable.name), 0o755);
647-
yield* fs.chmod(path.join(pairDirectory, asset.harness.name), 0o755);
649+
yield* fs.chmod(executablePath, 0o755);
650+
yield* fs.chmod(harnessPath, 0o755);
651+
}
652+
if (platform === "darwin" && arch === "x64") {
653+
// Google signs the Intel build with the hardened runtime but no JIT entitlement, so
654+
// libffi's writable+executable trampolines spin forever. Re-sign ad hoc after the hash check.
655+
const exitCode = yield* spawner
656+
.spawn(
657+
ChildProcess.make(
658+
"/usr/bin/codesign",
659+
["--force", "--sign", "-", executablePath, harnessPath],
660+
{ stdout: "ignore", stderr: "ignore" },
661+
),
662+
)
663+
.pipe(
664+
Effect.flatMap((child) => child.exitCode),
665+
Effect.scoped,
666+
);
667+
if (exitCode !== 0) {
668+
return yield* installationError(
669+
"extract",
670+
"Could not prepare the Antigravity runtime for this Mac. Check that codesign is available.",
671+
);
672+
}
648673
}
649674
yield* report("verifying", "Checking the downloaded runtime.");
650675
yield* validate(
651676
{
652-
executablePath: path.join(pairDirectory, asset.executable.name),
653-
harnessPath: path.join(pairDirectory, asset.harness.name),
677+
executablePath,
678+
harnessPath,
654679
source: "managed",
655680
version: asset.version,
656681
managedVersionDirectory: pairDirectory,
@@ -660,8 +685,11 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
660685
const record: InstalledRelease = {
661686
releaseId: asset.sha256,
662687
version: asset.version,
663-
executable: asset.executable,
664-
harness: asset.harness,
688+
executable: {
689+
name: asset.executable.name,
690+
bytes: Number((yield* fs.stat(executablePath)).size),
691+
},
692+
harness: { name: asset.harness.name, bytes: Number((yield* fs.stat(harnessPath)).size) },
665693
};
666694
yield* fs.writeFileString(
667695
path.join(pairDirectory, RELEASE_RECORD),

0 commit comments

Comments
 (0)