chenhg5/cc-connect · error

link Agy config %s: %w

Error message

link Agy config %s: %w

What it means

mirrorDirectoryEntries wraps errors from os.Symlink when linking each entry from the source config directory into the overlay target directory. It is thrown when creating a symlink fails — most commonly because the target name already exists (symlinks are not created over existing entries), or because the filesystem does not support symlinks.

Source

Thrown at agent/antigravity/permission_bridge.go:181

	return overlayConfigRoot, nil
}

func mirrorDirectoryEntries(sourceDir, targetDir string, skip map[string]bool) error {
	entries, err := os.ReadDir(sourceDir)
	if os.IsNotExist(err) {
		return nil
	}
	if err != nil {
		return fmt.Errorf("read Agy config directory %s: %w", sourceDir, err)
	}
	for _, entry := range entries {
		if skip[entry.Name()] {
			continue
		}
		source := filepath.Join(sourceDir, entry.Name())
		target := filepath.Join(targetDir, entry.Name())
		if err := os.Symlink(source, target); err != nil {
			return fmt.Errorf("link Agy config %s: %w", source, err)
		}
	}
	return nil
}

func shellQuote(value string) string {
	return "'" + strings.ReplaceAll(value, "'", "'\"'\"'") + "'"
}

func bridgeTokenEqual(got, want string) bool {
	if len(got) != len(want) {
		return false
	}
	return subtle.ConstantTimeCompare([]byte(got), []byte(want)) == 1
}

func (b *agyPermissionBridge) Env() []string {
	return []string{

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Remove the stale overlay target directory so it can be rebuilt: rm -rf <targetDir> then rerun.
  2. Ensure only one cc-connect instance runs at a time to avoid symlink races.
  3. On Windows, run with Developer Mode / symlink privilege enabled, or move the overlay to an NTFS volume.
  4. Check the wrapped cause in the message for EEXIST vs EPERM to distinguish stale-overlay from unsupported-symlink.

Example fix

// before (stale overlay)
$ ls overlay/
settings.json   <- leftover
// after
$ rm -rf overlay/ && cc-connect  # rebuilds symlinks cleanly
Defensive patterns

Strategy: validation

Validate before calling

if entries, err := os.ReadDir(targetDir); err == nil && len(entries) > 0 {
    // stale overlay — remove it before rebuilding
    os.RemoveAll(targetDir)
}

Try / catch

if err := mirrorDirectoryEntries(src, dst, skip); err != nil && strings.Contains(err.Error(), "link Agy config") {
    os.RemoveAll(dst)
    // retry once
}

Prevention

When it happens

Trigger: createAgyConfigOverlay calls mirrorDirectoryEntries on a target dir that already contains an entry with the same name; running on a platform/filesystem without symlink support (e.g. Windows without privilege, some FAT/network mounts).

Common situations: A previous run crashed leaving a partially populated overlay directory; two cc-connect instances racing to build the same overlay; Windows dev environments lacking symlink privileges.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/479078182f649cd1. Report an issue: GitHub.