{"record":{"id":"feedc4783763f383","repo":"lima-vm/lima","slug":"failed-to-create-temp-file-w","errorCode":null,"errorMessage":"failed to create temp file: %w","messagePattern":"failed to create temp file: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/autostart_darwin.go","lineNumber":120,"sourceCode":"\t}\n\n\tvars := map[string]string{\n\t\t\"Binary\":   selfExe,\n\t\t\"Instance\": instName,\n\t\t\"WorkDir\":  workDir,\n\t\t\"UserName\": userName,\n\t}\n\tif keepAlive {\n\t\tvars[\"KeepAlive\"] = \"true\"\n\t}\n\tcontent, err := textutil.ExecuteTemplate(launchd.DaemonTemplate, vars)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to render daemon plist: %w\", err)\n\t}\n\n\ttmp, err := os.CreateTemp(\"\", \"io.lima-vm.daemon.*.plist\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temp file: %w\", err)\n\t}\n\tdefer os.Remove(tmp.Name())\n\tif _, err := tmp.Write(content); err != nil {\n\t\treturn fmt.Errorf(\"failed to write temp plist: %w\", err)\n\t}\n\ttmp.Close()\n\n\tdestPath := launchd.GetDaemonPlistPath(instName)\n\tsvcTarget := \"system/\" + launchd.DaemonServiceNameFrom(instName)\n\n\t_ = runSudo(ctx, \"launchctl\", \"bootout\", svcTarget)\n\tif err := runSudo(ctx, \"install\", \"-m\", \"644\", tmp.Name(), destPath); err != nil {\n\t\treturn fmt.Errorf(\"failed to install plist to %s: %w\", destPath, err)\n\t}\n\tif err := runSudo(ctx, \"launchctl\", \"enable\", svcTarget); err != nil {\n\t\treturn fmt.Errorf(\"failed to enable LaunchDaemon: %w\", err)\n\t}\n\tif err := runSudo(ctx, \"launchctl\", \"bootstrap\", \"system\", destPath); err != nil {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/autostart_darwin.go#L102-L138","documentation":"This error wraps a failure from os.CreateTemp when daemonInstall tries to stage a rendered launchd plist in a temporary file before installing it to /Library/LaunchDaemons. It means the OS refused to create the temp file, almost always because TMPDIR is unwritable, full, or missing.","triggerScenarios":"Running `limactl autostart <instance> --condition=boot` on macOS when os.CreateTemp(\"\", \"io.lima-vm.daemon.*.plist\") fails: read-only or full TMPDIR, TMPDIR pointing at a nonexistent directory, sandbox/MDM restrictions on temp file creation, or TMPDIR being removed mid-session.","commonSituations":"Disk full on the boot volume; corporate security agents restricting temp dirs; running inside a sandboxed shell with a stale TMPDIR; /tmp mounted noexec/readonly on unusual setups.","solutions":["Check TMPDIR is set and writable: run `ls -ld \"$TMPDIR\"` and `touch \"$TMPDIR/test\"`","Free disk space if the volume is full (`df -h`)","Unset or fix a stale TMPDIR environment variable before rerunning limactl","Rerun the command outside any sandboxed/restricted shell"],"exampleFix":"// shell check before retrying\n// before: TMPDIR=/nonexistent limactl autostart myinstance --condition=boot\n// after:  unset TMPDIR && limactl autostart myinstance --condition=boot","handlingStrategy":"validation","validationCode":"if [ -z \"$TMPDIR\" ]; then TMPDIR=/tmp; fi\nif ! touch \"$TMPDIR/.lima-write-test\" 2>/dev/null; then\n  echo \"TMPDIR $TMPDIR is not writable\"; exit 1\nfi\nrm -f \"$TMPDIR/.lima-write-test\"\ndf -h \"$TMPDIR\" | awk 'NR==2 && $5+0 >= 95 {print \"temp volume nearly full\"; exit 1}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the temp volume under ~90% utilization","Never point TMPDIR at network or ephemeral mounts","Run limactl outside sandboxed/restricted shells","Verify TMPDIR exists before automation runs"],"tags":["macos","launchd","filesystem","temp-file"],"backgroundTag":"temp-file-creation-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}