{"record":{"id":"033180d9ae05126d","repo":"goreleaser/goreleaser","slug":"failed-to-write-to-file-w","errorCode":null,"errorMessage":"failed to write to file: %w","messagePattern":"failed to write to file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pipe/universalbinary/universalbinary.go","lineNumber":210,"sourceCode":"\t}\n\n\t// Build a fat_header.\n\thdr := []uint32{macho.MagicFat, uint32(len(inputs))}\n\n\t// Build a fat_arch for each input file.\n\tfor _, i := range inputs {\n\t\thdr = append(hdr, i.cpu)\n\t\thdr = append(hdr, i.subcpu)\n\t\thdr = append(hdr, uint32(i.offset))\n\t\thdr = append(hdr, uint32(len(i.data)))\n\t\thdr = append(hdr, alignBits)\n\t}\n\n\t// Write header.\n\t// Note that the fat binary header is big-endian, regardless of the\n\t// endianness of the contained files.\n\tif err := binary.Write(out, binary.BigEndian, hdr); err != nil {\n\t\treturn fmt.Errorf(\"failed to write to file: %w\", err)\n\t}\n\toffset = int64(4 * len(hdr))\n\n\t// Write each contained file.\n\tfor _, i := range inputs {\n\t\tif offset < i.offset {\n\t\t\tif _, err := out.Write(make([]byte, i.offset-offset)); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to write to file: %w\", err)\n\t\t\t}\n\t\t\toffset = i.offset\n\t\t}\n\t\tif _, err := out.Write(i.data); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to file: %w\", err)\n\t\t}\n\t\toffset += int64(len(i.data))\n\t}\n\n\tif err := out.Close(); err != nil {","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/goreleaser/goreleaser/blob/f5edd7395693c0c6b501dc722d445d2e86af854d/internal/pipe/universalbinary/universalbinary.go#L192-L228","documentation":"goreleaser's universal binary pipe (macOS fat binary creation) wraps any error returned by binary.Write when writing the big-endian fat header into the output file. This means the low-level write to the newly created output file (in dist/) failed, typically due to disk, I/O, or file-descriptor problems. It is a filesystem-level failure, not a configuration error.","triggerScenarios":"Writing the fat header via binary.Write(out, binary.BigEndian, hdr) fails while creating a universal (darwin_all) binary — e.g. disk full, I/O error, or the output file handle becoming invalid after os.Create succeeded in makeUniversalBinary.","commonSituations":"Disk quota/full disk on CI runners; ephemeral filesystem corruption; out-of-memory pressure causing short writes; running goreleaser in a container with a read-only or size-limited /dist volume; antivirus or indexing software locking files in dist/ on Windows/macOS.","solutions":["Check free disk space in the dist/ directory location and on the CI runner; clean up old dist/ artifacts","Re-run the release; transient I/O errors usually do not recur","Exclude dist/ from antivirus/backup/indexing tools or move dist to a local fast disk","Check container/volume size limits if running in Docker or with tmpfs"],"exampleFix":"// before (CI with tiny tmpfs)\nrules: ... # dist on tmpfs fills up\n// after\ngoreleaser release --clean # with dist on a persistent volume with >1GB free","handlingStrategy":"validation","validationCode":"func ensureDiskSpace(dir string, minBytes uint64) error {\n\tvar st syscall.Statfs_t\n\tif err := syscall.Statfs(dir, &st); err != nil {\n\t\treturn err\n\t}\n\tif uint64(st.Bavail)*uint64(st.Bsize) < minBytes {\n\t\treturn fmt.Errorf(\"insufficient disk space in %s\", dir)\n\t}\n\treturn nil\n}\n// call ensureDiskSpace(distDir, 1<<30) before running goreleaser","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Monitor free disk space on CI runners before releases","Keep dist/ on local, non-synced storage","Exclude dist/ from antivirus/indexing","Clean old dist artifacts with --clean"],"tags":["filesystem","io","macos","universal-binary"],"backgroundTag":"disk-write-failed","analyzedSha":"f5edd7395693c0c6b501dc722d445d2e86af854d","analyzedAt":"2026-09-05T09:57:18.807Z","contentChangedAt":"2026-09-05T09:57:18.807Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}