Skip to content

Commit 56a479c

Browse files
Alessio Fanoclaude
andcommitted
fix(server): Antigravity installs on Intel Macs
Google signs the darwin-x64 Antigravity ACP runtime with the hardened runtime but no JIT entitlement, so libffi's writable+executable trampolines spin forever and the install hangs at "Checking the downloaded runtime". Re-sign both binaries ad hoc after the SHA-256 check and record the signed sizes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cefb544 commit 56a479c

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";
@@ -641,15 +642,39 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
641642
}
642643
}).pipe(Effect.scoped);
643644
yield* fs.remove(archivePath);
645+
const executablePath = path.join(pairDirectory, asset.executable.name);
646+
const harnessPath = path.join(pairDirectory, asset.harness.name);
644647
if (platform !== "win32") {
645-
yield* fs.chmod(path.join(pairDirectory, asset.executable.name), 0o755);
646-
yield* fs.chmod(path.join(pairDirectory, asset.harness.name), 0o755);
648+
yield* fs.chmod(executablePath, 0o755);
649+
yield* fs.chmod(harnessPath, 0o755);
650+
}
651+
if (platform === "darwin" && arch === "x64") {
652+
// Google signs the Intel build with the hardened runtime but no JIT entitlement, so
653+
// libffi's writable+executable trampolines spin forever. Re-sign ad hoc after the hash check.
654+
const exitCode = yield* spawner
655+
.spawn(
656+
ChildProcess.make(
657+
"/usr/bin/codesign",
658+
["--force", "--sign", "-", executablePath, harnessPath],
659+
{ stdout: "ignore", stderr: "ignore" },
660+
),
661+
)
662+
.pipe(
663+
Effect.flatMap((child) => child.exitCode),
664+
Effect.scoped,
665+
);
666+
if (exitCode !== 0) {
667+
return yield* installationError(
668+
"extract",
669+
"Could not prepare the Antigravity runtime for this Mac. Check that codesign is available.",
670+
);
671+
}
647672
}
648673
yield* report("verifying", "Checking the downloaded runtime.");
649674
yield* validate(
650675
{
651-
executablePath: path.join(pairDirectory, asset.executable.name),
652-
harnessPath: path.join(pairDirectory, asset.harness.name),
676+
executablePath,
677+
harnessPath,
653678
source: "managed",
654679
version: asset.version,
655680
managedVersionDirectory: pairDirectory,
@@ -659,8 +684,11 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
659684
const record: InstalledRelease = {
660685
releaseId: asset.sha256,
661686
version: asset.version,
662-
executable: asset.executable,
663-
harness: asset.harness,
687+
executable: {
688+
name: asset.executable.name,
689+
bytes: Number((yield* fs.stat(executablePath)).size),
690+
},
691+
harness: { name: asset.harness.name, bytes: Number((yield* fs.stat(harnessPath)).size) },
664692
};
665693
yield* fs.writeFileString(
666694
path.join(pairDirectory, RELEASE_RECORD),

0 commit comments

Comments
 (0)