Skip to content

Commit a7bedbe

Browse files
jorotodorovvclaude
andcommitted
fix(antigravity): keep falling through PATH entries without a harness
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3de6f08 commit a7bedbe

2 files changed

Lines changed: 48 additions & 12 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,21 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst
759759
expect(
760760
yield* isolated.installation.resolve(executableName, { PATH: externalDirectory }),
761761
).toMatchObject({ source: "override", executablePath: externalExecutable });
762+
763+
const incompleteDirectory = path.join(baseDir, "incomplete");
764+
yield* fs.makeDirectory(incompleteDirectory);
765+
yield* fs.writeFileString(path.join(incompleteDirectory, executableName), "no harness", {
766+
mode: 0o755,
767+
});
768+
const shadowedPath = { PATH: `${incompleteDirectory}:${externalDirectory}` };
769+
expect(yield* isolated.installation.resolve(undefined, shadowedPath)).toMatchObject({
770+
source: "path",
771+
executablePath: externalExecutable,
772+
});
773+
expect(yield* isolated.installation.resolve(executableName, shadowedPath)).toMatchObject({
774+
source: "override",
775+
executablePath: externalExecutable,
776+
});
762777
}),
763778
);
764779

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

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,35 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
292292
} satisfies AntigravityExecutable;
293293
});
294294

295-
const commandPath = Effect.fn("AntigravityInstallation.commandPath")(function* (
296-
command: string,
297-
processEnvironment = environment,
298-
) {
299-
const resolved = yield* resolveCommandPath(command, { env: processEnvironment }).pipe(
295+
const commandPath = (command: string, env: NodeJS.ProcessEnv) =>
296+
resolveCommandPath(command, { env }).pipe(
297+
Effect.map((resolved) => (resolved === null ? null : path.resolve(resolved))),
300298
Effect.provideService(HostProcess.Platform, platform),
301299
Effect.provideService(FileSystem.FileSystem, fs),
302300
Effect.provideService(Path.Path, path),
303301
);
304-
return resolved === null ? null : path.resolve(resolved);
302+
303+
// Resolve per PATH entry so an executable without its harness falls through to later entries.
304+
const commandCandidates = Effect.fn("AntigravityInstallation.commandCandidates")(function* (
305+
command: string,
306+
processEnvironment = environment,
307+
) {
308+
if (command.includes("/") || command.includes("\\")) {
309+
const resolved = yield* commandPath(command, processEnvironment);
310+
return resolved === null ? [] : [resolved];
311+
}
312+
const pathValue =
313+
platform === "win32"
314+
? Object.entries(processEnvironment).findLast(([key]) => key.toUpperCase() === "PATH")?.[1]
315+
: processEnvironment.PATH;
316+
const candidates: string[] = [];
317+
for (const directory of (pathValue ?? "").split(platform === "win32" ? ";" : ":")) {
318+
const entry = directory.trim().replace(/^"|"$/gu, "");
319+
if (entry.length === 0) continue;
320+
const resolved = yield* commandPath(command, { ...processEnvironment, PATH: entry });
321+
if (resolved !== null) candidates.push(resolved);
322+
}
323+
return candidates;
305324
});
306325

307326
const resolve: AntigravityInstallationService["resolve"] = Effect.fn(
@@ -310,9 +329,10 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
310329
function* (binaryPath?: string, processEnvironment?: NodeJS.ProcessEnv) {
311330
const override = binaryPath?.trim();
312331
if (override) {
313-
const candidate = yield* commandPath(override, processEnvironment);
314-
const selected = candidate === null ? null : yield* fromExternal(candidate, "override");
315-
if (selected) return selected;
332+
for (const candidate of yield* commandCandidates(override, processEnvironment)) {
333+
const selected = yield* fromExternal(candidate, "override");
334+
if (selected) return selected;
335+
}
316336
return yield* installationError(
317337
"resolve",
318338
"The custom Antigravity executable is missing or not executable, or it needs a localharness_external sibling. The agy CLI does not.",
@@ -322,9 +342,10 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
322342
const active = yield* readRecord(activePath, ActiveRelease);
323343
return yield* completedRelease(active.releaseId);
324344
}
325-
const candidate = yield* commandPath(names.executable, processEnvironment);
326-
const selected = candidate === null ? null : yield* fromExternal(candidate, "path");
327-
if (selected) return selected;
345+
for (const candidate of yield* commandCandidates(names.executable, processEnvironment)) {
346+
const selected = yield* fromExternal(candidate, "path");
347+
if (selected) return selected;
348+
}
328349
return yield* installationError(
329350
"resolve",
330351
releaseAsset

0 commit comments

Comments
 (0)