{"record":{"id":"3e3b3a3cb587a28b","repo":"abiosoft/colima","slug":"error-closing-temporary-file-w","errorCode":null,"errorMessage":"error closing temporary file: %w","messagePattern":"error closing temporary file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/util.go","lineNumber":37,"sourceCode":"\tif err != nil {\n\t\tlogrus.Fatal(\"Error: \", err)\n\t}\n\treturn colimaApp\n}\n\n// waitForUserEdit launches a temporary file with content using editor,\n// and waits for the user to close the editor.\n// It returns the filename (if saved), empty file name (if aborted), and an error (if any).\nfunc waitForUserEdit(editor string, content []byte) (string, error) {\n\ttmp, err := os.CreateTemp(\"\", \"colima-*.yaml\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error creating temporary file: %w\", err)\n\t}\n\tif _, err := tmp.Write(content); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error writing temporary file: %w\", err)\n\t}\n\tif err := tmp.Close(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error closing temporary file: %w\", err)\n\t}\n\n\tif err := launchEditor(editor, tmp.Name()); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// aborted\n\tif f, err := os.ReadFile(tmp.Name()); err == nil && len(bytes.TrimSpace(f)) == 0 {\n\t\treturn \"\", nil\n\t}\n\n\treturn tmp.Name(), nil\n}\n\nvar editors = []string{\n\t\"vim\",\n\t\"code --wait --new-window\",\n\t\"nano\",","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/util.go#L19-L55","documentation":"Third error mode of waitForUserEdit: tmp.Close() fails while flushing/closing the temp file after writing. On local filesystems a close error usually means the final flush of buffered data hit ENOSPC or a device-level EIO; on network filesystems it can also surface locking/state errors. The file handle is left in an unknown state and the edit flow aborts.","triggerScenarios":"Writing content that fits in the buffer but cannot be flushed at close because the disk/quota filled; TMPDIR on NFS/FUSE with close-time errors; removable media yanked mid-flow.","commonSituations":"Disk-full conditions detected only at close; TMPDIR pointed at a network share in corporate setups; flaky USB drives hosting /tmp.","solutions":["Free space on the temp volume (`df -h \"${TMPDIR:-/tmp}\"`) and retry","Move TMPDIR to a healthy local volume: `TMPDIR=$HOME/tmp colima start --edit`","If TMPDIR is a network/FUSE mount, stop pointing TMPDIR at it for interactive edits","Repeated EIO on a local disk indicates filesystem/hardware trouble — check with `dmesg`/Disk Utility"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := startCmd.Execute(); err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        switch {\n        case errors.Is(perr.Err, syscall.ENOSPC):\n            // flush failed at close: free space, retry\n        case errors.Is(perr.Err, syscall.EIO):\n            // backing filesystem error: switch TMPDIR to a local volume, retry\n        }\n    }\n}","preventionTips":["Prefer a local disk for TMPDIR; close-time EIO is typical of NFS/FUSE temp mounts","Free disk space before editing when the volume is near capacity","Recurring EIO on local disks warrants filesystem/hardware checks, not retries"],"tags":["tempfile","close","disk-full","io"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}