{"record":{"id":"43417ad2bbdad665","repo":"github/copilot-sdk","slug":"failed-to-write-output-binary-w","errorCode":null,"errorMessage":"failed to write output binary: %w","messagePattern":"failed to write output binary: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":461,"sourceCode":"\t}\n\n\tif outputDir != \".\" {\n\t\tif err := os.MkdirAll(outputDir, 0755); err != nil {\n\t\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to create output directory: %w\", err)\n\t\t}\n\t}\n\tif includeLicense {\n\t\tif err := extractCLILicense(tarballPath, outputPath); err != nil {\n\t\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to extract CLI license: %w\", err)\n\t\t}\n\t}\n\n\tbinaryHash, err := sha256File(binaryPath)\n\tif err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to hash output binary: %w\", err)\n\t}\n\tif err := compressZstdFile(binaryPath, outputPath); err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to write output binary: %w\", err)\n\t}\n\n\trawLibPath := filepath.Join(tempDir, \"runtime.node\")\n\tif err := extractFileFromTarball(\n\t\ttarballPath,\n\t\ttempDir,\n\t\t\"package/prebuilds/\"+info.runtimePlatform+\"/runtime.node\",\n\t\t\"runtime.node\",\n\t); err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"runtime package is missing prebuilds/%s/runtime.node: %w\", info.runtimePlatform, err)\n\t}\n\truntimeHash, err := sha256File(rawLibPath)\n\tif err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to hash runtime.node: %w\", err)\n\t}\n\tif err := compressZstdFile(rawLibPath, runtimeArtifactPath); err != nil {\n\t\treturn bundleArtifacts{}, fmt.Errorf(\"failed to write runtime.node: %w\", err)\n\t}","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L443-L479","documentation":"buildBundle compresses the extracted CLI binary with Zstandard into the final output artifact via compressZstdFile. If compression or writing the .zst file fails, the error is wrapped with this message and the bundle is aborted. It covers both read failures on the source binary and write failures on the destination file.","triggerScenarios":"compressZstdFile(binaryPath, outputPath) errors: outputPath cannot be created/written (permissions, read-only fs), disk is full, or the source binary becomes unreadable mid-compression.","commonSituations":"Output directory on a full disk (large multi-hundred-MB binaries), running in a container with a read-only or small tmpfs output mount, or filesystem quota exceeded on the output volume.","solutions":["Free disk space or point --output at a volume with enough room for the compressed artifact (input binary size is a good lower bound).","Ensure the output directory is writable by the current user; pre-create it and chown if needed.","Check for filesystem quotas (quota -s) or tmpfs size limits if the output mount is /tmp or similar.","Re-run the build; transient I/O errors while writing large files can resolve on retry."],"exampleFix":"// before\nbundler --output /mnt/small-tmpfs/dist\n// no space left on device\n\n// after\nbundler --output /var/lib/build/dist   # larger persistent volume","handlingStrategy":"try-catch","validationCode":"if err := os.Chmod(outputPath, 0o644); err != nil {\n\treturn fmt.Errorf(\"output location %q not writable: %w\", outputPath, err)\n}\nprobe := outputPath + \".probe\"\nif err := os.WriteFile(probe, []byte(\"x\"), 0o644); err != nil {\n\treturn fmt.Errorf(\"cannot write to output volume: %w\", err)\n}\nos.Remove(probe)\nif stat, err := os.Stat(filepath.Dir(outputPath)); err == nil {\n\tif stat, _ := stat.Sys().(*syscall.Statfs_t); stat != nil && stat.Bavail*uint64(stat.Bsize) < 2<<30 {\n\t\treturn fmt.Errorf(\"output volume has <2GB free\")\n\t}\n}","typeGuard":"func canWriteTo(dir string) bool {\n\tf, err := os.CreateTemp(dir, \".probe*\")\n\tif err != nil {\n\t\treturn false\n\t}\n\tf.Close()\n\tos.Remove(f.Name())\n\treturn true\n}","tryCatchPattern":"if err := buildBundle(...); err != nil {\n\tif strings.Contains(err.Error(), \"failed to write output binary\") {\n\t\tvar pe *fs.PathError\n\t\tif errors.As(err, &pe) && errors.Is(err, syscall.ENOSPC) {\n\t\t\tfmt.Fprintln(os.Stderr, \"disk full on output volume; free space or choose another --output\")\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Verify the output volume has free space at least the size of the uncompressed binary before building.","Avoid read-only or small tmpfs mounts as the output directory.","Watch volume quotas on CI artifact directories.","Retain enough disk headroom for both raw and compressed artifacts during the build."],"tags":["zstd","compression","filesystem","disk-full"],"backgroundTag":"file-write-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}