{"record":{"id":"8a0b84fd77378c88","repo":"abiosoft/colima","slug":"error-writing-temp-file-w","errorCode":null,"errorMessage":"error writing temp file: %w","messagePattern":"error writing temp file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/process/vmnet/deps.go","lineNumber":64,"sourceCode":"func (v vmnetFile) Install(host environment.HostActions) error {\n\tarch := \"x86_64\"\n\tif runtime.GOARCH != \"amd64\" {\n\t\tarch = \"arm64\"\n\t}\n\n\t// read the embedded file\n\tgz, err := embedded.Read(\"network/vmnet_\" + arch + \".tar.gz\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error retrieving embedded vmnet file: %w\", err)\n\t}\n\n\t// write tar to tmp directory\n\tf, err := os.CreateTemp(\"\", \"vmnet.tar.gz\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating temp file: %w\", err)\n\t}\n\tif _, err := f.Write(gz); err != nil {\n\t\treturn fmt.Errorf(\"error writing temp file: %w\", err)\n\t}\n\t_ = f.Close() // not a fatal error\n\n\tdefer func() {\n\t\t_ = os.Remove(f.Name())\n\t}()\n\n\t// extract tar to desired location\n\tdir := optDir\n\tif err := host.RunInteractive(\"sudo\", \"mkdir\", \"-p\", dir); err != nil {\n\t\treturn fmt.Errorf(\"error preparing colima privileged dir: %w\", err)\n\t}\n\tif err := host.RunInteractive(\"sudo\", \"sh\", \"-c\", fmt.Sprintf(\"cd %s && tar xfz %s 2>/dev/null\", dir, f.Name())); err != nil {\n\t\treturn fmt.Errorf(\"error extracting vmnet archive: %w\", err)\n\t}\n\n\treturn nil\n}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/daemon/process/vmnet/deps.go#L46-L82","documentation":"Immediately after creating the temp file, vmnetFile.Install writes the embedded tarball bytes with f.Write(gz); failure wraps as 'error writing temp file'. Nearly always storage exhaustion mid-write: disk full or quota exceeded between CreateTemp and Write, tmpfs size limits, or the file having been closed/removed externally. The deferred os.Remove cleans up the partial file.","triggerScenarios":"disk fills between temp file creation and the multi-megabyte write; TMPDIR on a small tmpfs smaller than the vmnet tarball; file descriptors/quotas exhausted.","commonSituations":"machines nearly out of disk; CI containers with hard tmp size limits.","solutions":["check free space where TMPDIR lives: df -h $TMPDIR, then clean up","point TMPDIR at a larger writable filesystem and retry","retry the start once space is available — the partial temp file is auto-removed by the deferred cleanup"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var stat syscall.Statfs_t\nif err := syscall.Statfs(os.TempDir(), &stat); err == nil {\n    free := stat.Bavail * uint64(stat.Bsize)\n    if free < 50<<20 { // tarball is a few MB; require headroom\n        return fmt.Errorf(\"less than 50MB free in %s — free space first\", os.TempDir())\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := f.Write(gz); err != nil {\n    _ = f.Close()\n    _ = os.Remove(f.Name()) // partial file cleanup; ENOSPC: free space then retry install\n    return fmt.Errorf(\"error writing temp file: %w\", err)\n}","preventionTips":["keep headroom on the temp filesystem when using --network-address","prefer a disk-backed TMPDIR over small tmpfs for privileged installs","retry the vmnet install after freeing space — Install is idempotent"],"tags":["disk-space","filesystem","temp-files","vmnet"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}