chenhg5/cc-connect · error

cc-connect binary not found in zip archive

Error message

cc-connect binary not found in zip archive

What it means

extractBinaryFromZip scans the downloaded zip's entries and returns this error when no file entry whose basename starts with "cc-connect" is found. The downloaded zip is valid but lacks the expected binary member.

Source

Thrown at core/updater.go:242

}

func extractBinaryFromZip(data []byte) ([]byte, error) {
	r, err := zip.NewReader(bytes.NewReader(data), int64(len(data)))
	if err != nil {
		return nil, err
	}
	for _, f := range r.File {
		name := filepath.Base(f.Name)
		if strings.HasPrefix(name, "cc-connect") && !f.FileInfo().IsDir() {
			rc, err := f.Open()
			if err != nil {
				return nil, err
			}
			defer rc.Close()
			return io.ReadAll(rc)
		}
	}
	return nil, fmt.Errorf("cc-connect binary not found in zip archive")
}

func replaceBinary(newBinary []byte) error {
	execPath, err := os.Executable()
	if err != nil {
		return fmt.Errorf("get executable path: %w", err)
	}
	execPath, err = filepath.EvalSymlinks(execPath)
	if err != nil {
		return fmt.Errorf("resolve symlinks: %w", err)
	}

	dir := filepath.Dir(execPath)
	tmpFile, err := os.CreateTemp(dir, "cc-connect-update-*")
	if err != nil {
		return fmt.Errorf("create temp file: %w", err)
	}
	tmpPath := tmpFile.Name()

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Run `unzip -l <archive>` to list members and verify a file starting with cc-connect exists at some depth.
  2. Fix the release packaging so the binary member is named cc-connect* (zip is used for zip archives regardless of a .tar.gz extension mismatch).
  3. If the binary is inside the zip but under a new name, update the updater's HasPrefix match accordingly.
  4. Re-download from the official release URL — a mirror may host repackaged archives with renamed binaries.
  5. Manual fallback: unzip, rename the binary to cc-connect, and replace the installed executable yourself.

Example fix

// packaging: before
zip cc-connect-windows-amd64.zip agent.exe
// after
zip cc-connect-windows-amd64.zip cc-connect.exe
Defensive patterns

Strategy: validation

Validate before calling

r, err := zip.OpenReader(archivePath)
if err == nil {
    found := false
    for _, f := range r.File {
        if strings.HasPrefix(filepath.Base(f.Name), "cc-connect") {
            found = true
        }
    }
    if !found {
        return fmt.Errorf("zip lacks cc-connect binary")
    }
}

Prevention

When it happens

Trigger: SelfUpdate routed a zip archive to extraction and every f.Name's basename failed the strings.HasPrefix(name, "cc-connect") check, or the matching entry is a directory: wrong artifact (docs/source zip), binary renamed inside the archive, empty zip, or only directory entries.

Common situations: Windows/macOS release asset changed its internal binary name; user hand-built and zipped artifacts with a different name; download URL pointing to the wrong platform's bundle; interrupted/zero-byte upload producing an empty zip.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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