chenhg5/cc-connect · error
backup old binary: %w
Error message
backup old binary: %w
What it means
Wraps a failed os.Rename moving the current executable aside to <target>.old in replaceExecutable (the Windows-safe swap path). It fires when the running binary cannot be renamed — target missing, permission denied, or antivirus locking the file on Windows.
Source
Thrown at cmd/cc-connect/update.go:439
}
tmp.Close()
fmt.Printf("Downloaded %.1f MB\n", float64(size)/1024/1024)
return tmp.Name(), nil
}
func replaceExecutable(target, src string) error {
if err := os.Chmod(src, 0o755); err != nil {
return fmt.Errorf("chmod: %w", err)
}
// On Windows, rename over a running exe is not possible directly.
// Move old binary aside, then move new one in.
backup := target + ".old"
os.Remove(backup)
if err := os.Rename(target, backup); err != nil {
return fmt.Errorf("backup old binary: %w", err)
}
if err := copyFile(src, target); err != nil {
// Attempt to restore
if restoreErr := os.Rename(backup, target); restoreErr != nil {
slog.Warn("update: failed to restore old binary after copy error", "error", restoreErr)
}
return fmt.Errorf("install new binary: %w", err)
}
if err := os.Chmod(target, 0o755); err != nil {
return fmt.Errorf("chmod new binary: %w", err)
}
os.Remove(backup)
return nil
}
View on GitHub (pinned to 4000b2338a)
Solutions
- On Windows, exclude the cc-connect directory from antivirus locking
- Ensure the install directory is writable by the updating user
- Retry once the lock is released
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at cmd/cc-connect/update.go:439 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/ff762472a3fccfef.
Report an issue: GitHub.