github/copilot-sdk · error

failed to open release package

Error message

failed to open release package: %w

What it means

extractCLILicense skips work when the license already exists; otherwise it opens the downloaded release tarball to pull out package/LICENSE.md. If os.Open(tarballPath) fails, this error wraps it. It means the saved tarball is not readable at the path downloadCLIBinary reported.

Solutions

  1. Ensure the tarball from downloadCLIBinary is retained until extractCLILicense has run.
  2. Verify tarballPath exists and is readable (ls -l) before calling buildBundle steps manually.
  3. Avoid sharing temp directories across concurrent builds; use isolated dirs.
  4. Re-download the release if the tarball is gone.

Example fix

// before: removing tarball before license extraction
os.Remove(tarballPath)
extractCLILicense(tarballPath, outputDir, licensePath)

// after: extract license first, clean up afterwards
extractCLILicense(tarballPath, outputDir, licensePath)
os.Remove(tarballPath)
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(tarballPath); err != nil {
    return fmt.Errorf("release tarball %s unavailable before license extraction: %w", tarballPath, err)
}

Try / catch

if err := buildBundle(...); err != nil {
    if strings.Contains(err.Error(), "failed to open release package") {
        reDownload(); return retryBuild()
    }
    return err
}

Prevention

When it happens

Trigger: os.Open(tarballPath) returns non-nil — the tarball was deleted between download and license extraction, the path is wrong, or permission to read it is missing.

Common situations: Concurrent build cleaned the temp tarball; tarball removed by a cleanup step; running extractCLILicense with a hand-supplied path that doesn't exist; restrictive umask/permissions.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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

Appendix: source

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

	fmt.Printf("Downloaded %s (%.1f MB)\n", binaryName, sizeMB)

	return binaryPath, tarballPath, nil
}

// extractCLILicense writes the license from the verified release package next to outputPath.
func extractCLILicense(tarballPath, outputPath string) error {
	outputDir := filepath.Dir(outputPath)
	if outputDir == "" {
		outputDir = "."
	}
	licensePath := licensePathForOutput(outputPath)
	if _, err := os.Stat(licensePath); err == nil {
		return nil
	}

	source, err := os.Open(tarballPath)
	if err != nil {
		return fmt.Errorf("failed to open release package: %w", err)
	}
	defer source.Close()

	gzReader, err := gzip.NewReader(source)
	if err != nil {
		return fmt.Errorf("failed to create gzip reader: %w", err)
	}
	defer gzReader.Close()

	tarReader := tar.NewReader(gzReader)
	for {
		header, err := tarReader.Next()
		if err == io.EOF {
			break
		}
		if err != nil {
			return fmt.Errorf("failed to read tar: %w", err)
		}

View on GitHub (pinned to cd8cf15dc3)