#1870·codegraph

`install --refresh` creates `.backup` files in configs of agents that aren't configured

Author: Gotman08Created Sep 14, 2026Updated Sep 14, 2026

What happens

I have Antigravity installed, with an empty ~/.gemini/config/mcp_config.json (0 bytes). CodeGraph is not configured for Antigravity.

Running codegraph install --refresh --location global (CodeGraph 1.6.0, Windows 11) prints:

Warning: Could not parse mcp_config.json: Unexpected end of JSON input
A backup will be created before overwriting.

It then creates ~/.gemini/config/mcp_config.json.backup. Nothing is actually overwritten, since Antigravity is skipped as not configured, but the backup file stays behind and the warning suggests the config is about to be rewritten.

Why

detect() in src/installer/targets/antigravity.ts calls readJsonFile(). When a file can't be parsed, readJsonFile() in src/installer/targets/shared.ts copies it to <path>.backup. Detection is meant to be read-only, but it inherits this side effect, and a refresh runs detection for every target.

Suggestion

  • Only create the backup right before an actual write, so that detection never touches the disk.
  • Treat an empty file as {} without printing a warning.