github/copilot-sdk · error
failed to extract license: copy error
Error message
failed to extract license: copy error: %v; close error: %w
What it means
During io.Copy of the tar entry into the output file, the copy failed AND the deferred cleanup call to outFile.Close() also returned an error. Both the original copy error and the close error are embedded in the message so neither root cause is lost.
Solutions
- Re-download or re-fetch the tarball to rule out corruption/truncation
- Check disk space and quotas on the output filesystem
- Fix the close error cause (permissions, I/O errors) reported after the '; close error:' part
- Verify the tarball integrity (checksum) before extraction
Defensive patterns
Strategy: validation
Validate before calling
if err := verifyChecksum(tarballPath, expectedSHA256); err != nil { return fmt.Errorf("tarball corrupt before extraction: %w", err) }
if free, err := diskFree(outputDir); err == nil && free < minRequiredBytes { return fmt.Errorf("insufficient disk space") } Try / catch
if err := extractCLILicense(tarballPath, outputDir); err != nil {
var cw combinedWriteError
if errors.As(err, &cw) { log.Printf("copy: %v, close: %v", cw.CopyErr, cw.CloseErr) }
return err
} Prevention
- Verify checksums of downloaded artifacts before extraction
- Ensure adequate free disk space before bundling
- Re-download rather than retry on corrupted archives
- Avoid extraction onto flaky network filesystems
When it happens
Trigger: extractFileFromTarballStream (from extractCLILicense) hits a read failure on the tar/gzip stream (corrupt tarball, truncated download, decompression error) or a write failure (disk full) while closing the partially written file also fails.
Common situations: Interrupted/partial download of the CLI tarball; corrupted gzip data; disk quota exhausted mid-write; NFS/network volume flakiness.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- failed to extract binary
- failed to read checksums
- failed to save tarball
- failed to close tarball file
- failed to create gzip reader
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/be2cc28c03a30071.
Report an issue: GitHub.
Appendix: source
Thrown at go/cmd/bundler/main.go:1142
}
func licenseFileName(binaryName string) string {
if strings.HasSuffix(binaryName, ".zst") {
return strings.TrimSuffix(binaryName, ".zst") + ".license"
}
return binaryName + ".license"
}
// extractFileFromTarballStream writes the current tar entry to disk.
func extractFileFromTarballStream(r io.Reader, destDir, outputName string, mode os.FileMode) error {
outPath := filepath.Join(destDir, outputName)
outFile, err := os.OpenFile(outPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode)
if err != nil {
return fmt.Errorf("failed to create output file: %w", err)
}
if _, err := io.Copy(outFile, r); err != nil {
if cerr := outFile.Close(); cerr != nil {
return fmt.Errorf("failed to extract license: copy error: %v; close error: %w", err, cerr)
}
return fmt.Errorf("failed to extract license: %w", err)
}
return outFile.Close()
}
// extractFileFromTarball extracts a single file from a .tgz into destDir with a new name.
func extractFileFromTarball(tarballPath, destDir, targetPath, outputName string) error {
file, err := os.Open(tarballPath)
if err != nil {
return err
}
defer file.Close()
gzReader, err := gzip.NewReader(file)
if err != nil {
return fmt.Errorf("failed to create gzip reader: %w", err)
}View on GitHub (pinned to cd8cf15dc3)