chenhg5/cc-connect · error

download failed from all sources: %w

Error message

download failed from all sources: %w

What it means

SelfUpdate (core/updater.go:155) returns this when downloading the release archive failed from every configured download URL (GitHub and Gitee release assets). `lastErr` wraps the final download attempt's error (network failure, non-200 like 404 for a missing asset, redirect loop, timeout). No binary was downloaded, so the update is safely aborted before any file changes.

Source

Thrown at core/updater.go:155

	giteeURL := fmt.Sprintf("%s/%s/%s", giteeDownload, tag, filename)
	githubURL := fmt.Sprintf("%s/%s/%s", githubDownload, tag, filename)
	urls := []string{githubURL, giteeURL}
	if preferGitee {
		urls = []string{giteeURL, githubURL}
	}

	var data []byte
	var lastErr error
	for _, u := range urls {
		slog.Info("updater: downloading", "url", u)
		data, lastErr = downloadFile(u)
		if lastErr == nil {
			break
		}
		slog.Debug("updater: download failed, trying next", "error", lastErr)
	}
	if lastErr != nil && data == nil {
		return fmt.Errorf("download failed from all sources: %w", lastErr)
	}

	var binary []byte
	var err error
	if goos == "windows" {
		binary, err = extractBinaryFromZip(data)
	} else {
		binary, err = extractBinaryFromTarGz(data)
	}
	if err != nil {
		return fmt.Errorf("extract binary: %w", err)
	}

	return replaceBinary(binary)
}

func downloadFile(url string) ([]byte, error) {
	client := &http.Client{

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the wrapped error: 'HTTP 404' means the asset for your tag/OS/arch doesn't exist — verify the release page has `cc-connect-<tag>-<goos>-<goarch>` for your platform.
  2. Check network reachability of the printed download URLs (`updater: downloading url=...` in the logs) with curl; if GitHub is blocked, retry with preferGitee=true.
  3. Verify the tag passed to SelfUpdate exactly matches a published release tag (e.g. v1.2.3, with the `v` prefix).
  4. Set HTTPS_PROXY if a corporate proxy is required, then retry the upgrade command.
  5. If no release works, fall back to installing manually from the release page or via go install / package manager.

Example fix

// before: error shows only the last source's failure
return fmt.Errorf("download failed from all sources: %w", lastErr)

// after: report every attempted URL so users can test them directly
return fmt.Errorf("download failed from all sources (%v): %w", urls, lastErr)
Defensive patterns

Strategy: retry

Validate before calling

func assetURLWorks(tag, goos, goarch string) error {
	ext := ".tar.gz"
	if goos == "windows" {
		ext = ".zip"
	}
	u := fmt.Sprintf("https://github.com/chenhg5/cc-connect/releases/download/%s/cc-connect-%s-%s-%s%s", tag, tag, goos, goarch, ext)
	resp, err := http.Head(u)
	if err != nil {
		return err
	}
	resp.Body.Close()
	if resp.StatusCode != 200 {
		return fmt.Errorf("asset missing: HTTP %d for %s", resp.StatusCode, u)
	}
	return nil
}

Try / catch

if err := core.SelfUpdate(tag, preferGitee); err != nil {
	if strings.Contains(err.Error(), "download failed from all sources") {
		slog.Error("upgrade aborted; no binary was modified", "err", err)
		// safe to retry later or with the other mirror
		return fmt.Errorf("upgrade aborted: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Both `downloadFile` attempts fail: the release asset `cc-connect-<tag>-<goos>-<goarch>.tar.gz|.zip` does not exist (404 — wrong tag or missing platform build), the download times out (5-minute limit), a non-200 status is returned (error at line 195), a redirect loop hits the >10 limit (error 919), or both hosts are unreachable. Called by cmdUpgradeConfirm after the user confirms an upgrade.

Common situations: User confirms upgrade to a tag whose assets were never published for their OS/arch; GitHub release asset URLs broken after repo transfer; firewall blocking github.com release downloads (objects.githubusercontent.com); China networks failing to reach GitHub while Gitee mirror also lacks the asset; proxy misconfiguration.

Related errors


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