{"record":{"id":"703fe3b5b42befc1","repo":"abiosoft/colima","slug":"error-creating-temporary-file-w","errorCode":null,"errorMessage":"error creating temporary file: %w","messagePattern":"error creating temporary file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/util.go","lineNumber":31,"sourceCode":"\t\"github.com/abiosoft/colima/cli\"\n\t\"github.com/sirupsen/logrus\"\n)\n\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","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/util.go#L13-L49","documentation":"First error mode of waitForUserEdit (used by `colima start --edit` and `colima template`): os.CreateTemp(\"\", \"colima-*.yaml\") fails, so no scratch file for the editor could be created. The wrapped error is almost always a TMPDIR problem: the directory in TMPDIR does not exist, is unwritable, the inode/file-name space is exhausted, or the disk is full.","triggerScenarios":"TMPDIR pointing to a deleted directory; /tmp mounted noexec/read-only or with wrong ownership; ENOSPC on the temp filesystem; system-wide open-file limit reached.","commonSituations":"CI containers with a broken TMPDIR; macOS disk-pressure conditions; sandboxes that mount /tmp read-only; TMPDIR inherited from a crashed session.","solutions":["Check the wrapped error and your temp dir: `echo \"$TMPDIR\"; ls -ld \"${TMPDIR:-/tmp}\"; touch \"${TMPDIR:-/tmp}/probe\"`","Point TMPDIR somewhere writable: `TMPDIR=$HOME/tmp colima start --edit` (create the dir first)","Free space on the volume hosting the temp dir","Fix ownership if /tmp or TMPDIR is not writable by your user"],"exampleFix":"# before\n$ colima start --edit\nError: error editing config file: error creating temporary file: open /tmp/colima-1234.yaml: permission denied\n\n# after\n$ mkdir -p ~/tmp && TMPDIR=~/tmp colima start --edit","handlingStrategy":"validation","validationCode":"// Verify the temp dir is usable before any interactive colima command\ndir := os.TempDir() // honors TMPDIR\nif _, err := os.Stat(dir); err != nil {\n    log.Fatalf(\"TMPDIR %q does not exist: %v\", dir, err)\n}\nif f, err := os.CreateTemp(dir, \"probe-*\"); err != nil {\n    log.Fatalf(\"cannot create temp files in %s: %v\", dir, err)\n} else {\n    f.Close()\n    os.Remove(f.Name())\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, os.ErrPermission) {\n        // TMPDIR permission issue: export TMPDIR=$HOME/tmp and retry\n    }\n}","preventionTips":["Set TMPDIR to a known-writable local directory in containers/CI","Monitor /tmp volume space and inode usage","Avoid pointing TMPDIR at network filesystems for interactive colima flows"],"tags":["tempfile","filesystem","tmpdir","editor"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}