{"record":{"id":"ba16344a2aa63013","repo":"abiosoft/colima","slug":"error-writing-temporary-file-w","errorCode":null,"errorMessage":"error writing temporary file: %w","messagePattern":"error writing temporary file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/util.go","lineNumber":34,"sourceCode":"\nfunc newApp() app.App {\n\tcolimaApp, err := app.New()\n\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{","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/util.go#L16-L52","documentation":"Second error mode of waitForUserEdit: the freshly created temp file exists but tmp.Write(content) fails while writing the editor's initial content (abort header + current config/template). With the file already open and created, this is effectively always an I/O-level failure — ENOSPC (disk/quota full) or EIO on the temp filesystem.","triggerScenarios":"Disk filling exactly between CreateTemp and Write; per-user quota exceeded on the volume hosting TMPDIR; failing/USB-backed temp filesystem returning EIO.","commonSituations":"macOS low-disk warnings ignored; Docker/CI runners with small tmpfs quotas; large config plus nearly-full disk.","solutions":["Free space on the temp volume and retry the edit command","Check quotas if on a shared system: `quota -s` / `df -h \"${TMPDIR:-/tmp}\"`","Redirect temp writes to another volume: `TMPDIR=$HOME/tmp colima start --edit`","If EIO persists, suspect hardware/filesystem corruption on the temp mount"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Cheap space check before editing large configs\nvar stat syscall.Statfs_t\nif err := syscall.Statfs(os.TempDir(), &stat); err == nil {\n    free := stat.Bavail * uint64(stat.Bsize)\n    if free < 1<<20 { // < 1 MiB\n        log.Fatal(\"temp filesystem nearly full; free space before editing\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := startCmd.Execute(); err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) && errors.Is(perr.Err, syscall.ENOSPC) {\n        // free space on the temp volume and retry once\n    }\n}","preventionTips":["Keep the temp volume above a small space floor before interactive commands","Set per-user quotas with headroom on shared systems","On ENOSPC errors, clean caches (brew, Docker build cache) and retry"],"tags":["tempfile","disk-full","io","editor"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}