{"record":{"id":"3b80acd281f321dd","repo":"chenhg5/cc-connect","slug":"resolve-cc-connect-executable-for-agy-hook-w","errorCode":null,"errorMessage":"resolve cc-connect executable for Agy hook: %w","messagePattern":"resolve cc-connect executable for Agy hook: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/antigravity/permission_bridge.go","lineNumber":134,"sourceCode":"\t\treturn \"\", err\n\t}\n\n\thooks := make(map[string]json.RawMessage)\n\thooksPath := filepath.Join(realConfigDir, \"hooks.json\")\n\tif data, err := os.ReadFile(hooksPath); err == nil {\n\t\tif err := json.Unmarshal(data, &hooks); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"parse existing Agy hooks %s: %w\", hooksPath, err)\n\t\t}\n\t\tif hooks == nil {\n\t\t\thooks = make(map[string]json.RawMessage)\n\t\t}\n\t} else if !os.IsNotExist(err) {\n\t\treturn \"\", fmt.Errorf(\"read existing Agy hooks %s: %w\", hooksPath, err)\n\t}\n\n\texecutable, err := os.Executable()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"resolve cc-connect executable for Agy hook: %w\", err)\n\t}\n\tbridgeHook, err := json.Marshal(map[string]any{\n\t\t\"PreToolUse\": []any{\n\t\t\tmap[string]any{\n\t\t\t\t\"matcher\": \"*\",\n\t\t\t\t\"hooks\": []any{\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\":    \"command\",\n\t\t\t\t\t\t\"command\": shellQuote(executable) + \" _agy-permission-hook\",\n\t\t\t\t\t\t\"timeout\": 86400,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"marshal Agy permission hook: %w\", err)\n\t}","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/antigravity/permission_bridge.go#L116-L152","documentation":"The permission bridge needs the absolute path of the cc-connect binary to embed as the hook command in the generated hooks.json. If os.Executable fails (cannot determine the running executable's path), createAgyConfigOverlay returns this wrapped error.","triggerScenarios":"newAgyPermissionBridge → createAgyConfigOverlay when os.Executable returns an error — essentially only when the executable has been deleted or renamed after start, or on exotic platforms where /proc-style lookup fails.","commonSituations":"cc-connect binary deleted/replaced on disk while running (e.g. after an upgrade with an installer that unlinks first), running via a wrapper that removed the temp binary (go run scratch builds that vanish), or unusual chroot environments.","solutions":["Run cc-connect from a stable installed binary path, not a temporary build output that gets deleted.","Restart cc-connect after upgrading/replacing the binary so os.Executable resolves a valid path.","Avoid deleting or moving the executable while the process runs (use atomic install: write new file, rename over old).","If using `go run`, build a binary first (`go build -o /usr/local/bin/cc-connect`) and run that instead."],"exampleFix":"// before\ngo run ./cmd/cc-connect   # temp binary may be removed\n// after\ngo build -o /usr/local/bin/cc-connect ./cmd/cc-connect && /usr/local/bin/cc-connect","handlingStrategy":"fallback","validationCode":"// shell: ensure the running binary exists on disk before relying on hooks\npidBin=$(readlink -f /proc/$$/exe)\n[ -x \"$pidBin\" ] || echo \"running executable missing from disk\"","typeGuard":null,"tryCatchPattern":"if err := startAntigravitySession(); err != nil && strings.Contains(err.Error(), \"resolve cc-connect executable\") {\n    // restart the process from a stable installed path\n}","preventionTips":["Install binaries at stable paths and restart after upgrades.","Use atomic installs (write temp, rename) so the live binary is never deleted.","Avoid `go run` in production; run a built binary."],"tags":["executable","os","antigravity","go"],"backgroundTag":"resource-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}