Skip to content

fix(installer): resolve Antigravity codegraph command out of fnm's ephemeral per-shell dir#1444

Open
kevocodes wants to merge 1 commit into
colbymchenry:mainfrom
kevocodes:fix/antigravity-fnm-ephemeral-command-path
Open

fix(installer): resolve Antigravity codegraph command out of fnm's ephemeral per-shell dir#1444
kevocodes wants to merge 1 commit into
colbymchenry:mainfrom
kevocodes:fix/antigravity-fnm-ephemeral-command-path

Conversation

@kevocodes

Copy link
Copy Markdown

Overview

On macOS with fnm, the Antigravity installer writes an MCP command that points into an ephemeral, per-shell directory. It works at install time but dangles once the installing shell exits, so Antigravity can no longer spawn the codegraph server.

Fixes #1443.

Root cause

resolveCodegraphCommand() (src/installer/targets/antigravity.ts) resolves the absolute path via command -v codegraph. Under fnm, an interactive shell resolves codegraph to ~/.local/state/fnm_multishells/<pid>_<ts>/bin/codegraph — a symlink directory fnm creates per shell and removes when that shell exits. That path is written verbatim into ~/.gemini/config/mcp_config.json.

Change

Canonicalize the resolved path's containing directory with fs.realpathSync, then re-join the basename:

return path.join(fs.realpathSync(path.dirname(resolved)), path.basename(resolved));
  • Escapes the ephemeral fnm_multishells/<pid> dir, so the written path outlives the installing shell. For fnm it yields ~/.local/share/fnm/node-versions/<ver>/installation/bin/codegraph.
  • Preserves the codegraph basename. Some agents validate the MCP command by filepath.Base, so keeping the name matters — resolving the full path would land on npm-shim.js and break those checks.
  • Falls back to the raw resolved path if realpath throws.
  • No behavior change off macOS/fnm, or when resolution already yields a stable path.

Verification

  • npx tsc --noEmit — clean.
  • npx vitest run __tests__/installer-targets.test.ts — 162/162 pass.
  • Manual repro on macOS + fnm: command -v codegraph~/.local/state/fnm_multishells/<pid>/bin/codegraph (dangles after the shell exits); after the change the written command resolves to the stable node-versions/<ver>/installation/bin/codegraph and runs.

Note on tests

Happy to add a regression test. resolveCodegraphCommand isn't exported and the suite intentionally doesn't mock execSync, so a deterministic test needs a small seam (export the function, or mock child_process). Glad to go whichever way you prefer.

…hemeral per-shell dir

- resolveCodegraphCommand resolved `command -v codegraph`, which under fnm returns an ephemeral ~/.local/state/fnm_multishells/<pid>/bin path that fnm removes when the installing shell exits, leaving a dangling MCP command
- realpath the containing directory so the written command survives shell exit
- preserve the `codegraph` basename so agents that validate the command by basename still match
- fall back to the raw resolved path if realpath fails
@kevocodes
kevocodes force-pushed the fix/antigravity-fnm-ephemeral-command-path branch from 029f6ea to 8d37eb2 Compare July 24, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Antigravity installer writes an ephemeral fnm per-shell path as the MCP command

1 participant