github/copilot-sdk · error

failed to download CLI binary

Error message

failed to download CLI binary: %w

What it means

buildBundle failed to download the CLI binary/tarball for the target platform via downloadCLIBinary after creating the temp dir. This error wraps whatever downloadCLIBinary returned — typically an HTTP failure fetching the release asset, a 404 for the version/platform combination, or a checksum/extract failure.

Solutions

  1. Verify cliVersion corresponds to an existing release with assets for the platform.
  2. Check network/proxy access to the release download host.
  3. Confirm runtimePlatform/binaryName map to a real published asset name.
  4. If rate limited (403), use authenticated requests or retry after the limit window.
  5. Pin to a known-good cliVersion and rerun.

Example fix

// before
binaryPath, tarballPath, err := downloadCLIBinary(info.runtimePlatform, info.binaryName, cliVersion, tempDir)
if err != nil {
	return bundleArtifacts{}, fmt.Errorf("failed to download CLI binary: %w", err)
}
// after
binaryPath, tarballPath, err := downloadCLIBinary(info.runtimePlatform, info.binaryName, cliVersion, tempDir)
if err != nil {
	return bundleArtifacts{}, fmt.Errorf("failed to download CLI binary %s for %s: %w", cliVersion, info.runtimePlatform, err)
}
Defensive patterns

Strategy: retry

Validate before calling

// preflight: check the release asset exists before downloading
u := fmt.Sprintf(releaseURLFmt, cliVersion, info.binaryName)
resp, err := http.Head(u)
if err != nil || resp.StatusCode != http.StatusOK {
	return fmt.Errorf("CLI binary %s for %s unavailable (status %v)", cliVersion, info.runtimePlatform, resp)
}

Try / catch

artifacts, err := buildBundle(...)
if err != nil && strings.Contains(err.Error(), "failed to download CLI binary") {
	// retry with backoff; if still failing, verify cliVersion/release exists
	time.Sleep(5 * time.Second)
	artifacts, err = buildBundle(...)
}

Prevention

When it happens

Trigger: downloadCLIBinary(info.runtimePlatform, info.binaryName, cliVersion, tempDir) returns an error — bad cliVersion (no release exists), unsupported runtimePlatform/binaryName combination, network failure, or GitHub rate limiting on the release asset URL.

Common situations: cliVersion resolved from a stale package.json/lockfile pointing at a deleted release; downloading for a platform with no published binary; offline CI; asset renamed upstream between versions.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/937aa32596b37ece. Report an issue: GitHub.

Appendix: source

Thrown at go/cmd/bundler/main.go:442

			return bundleArtifacts{}, fmt.Errorf("failed to hash existing runtime wrapper: %w", err)
		}
		assetsHash, err := sha256File(assetsArtifactPath)
		if err != nil {
			return bundleArtifacts{}, fmt.Errorf("failed to hash existing runtime assets: %w", err)
		}
		return bundleArtifacts{outputPath, binaryHash, runtimeArtifactPath, runtimeHash, wrapperArtifactPath, wrapperHash, assetsArtifactPath, assetsHash}, nil
	}

	// Create temp directory for download
	tempDir, err := os.MkdirTemp("", "copilot-bundler-*")
	if err != nil {
		return bundleArtifacts{}, fmt.Errorf("failed to create temp dir: %w", err)
	}
	defer os.RemoveAll(tempDir)

	binaryPath, tarballPath, err := downloadCLIBinary(info.runtimePlatform, info.binaryName, cliVersion, tempDir)
	if err != nil {
		return bundleArtifacts{}, fmt.Errorf("failed to download CLI binary: %w", err)
	}

	if outputDir != "." {
		if err := os.MkdirAll(outputDir, 0755); err != nil {
			return bundleArtifacts{}, fmt.Errorf("failed to create output directory: %w", err)
		}
	}
	if includeLicense {
		if err := extractCLILicense(tarballPath, outputPath); err != nil {
			return bundleArtifacts{}, fmt.Errorf("failed to extract CLI license: %w", err)
		}
	}

	binaryHash, err := sha256File(binaryPath)
	if err != nil {
		return bundleArtifacts{}, fmt.Errorf("failed to hash output binary: %w", err)
	}
	if err := compressZstdFile(binaryPath, outputPath); err != nil {

View on GitHub (pinned to cd8cf15dc3)