{"record":{"id":"15ea3bb49e1c8e8a","repo":"lima-vm/lima","slug":"failed-to-create-temporary-directory-w-preservi","errorCode":null,"errorMessage":"failed to create temporary directory: %w; preserving guest synced workdir at %s","messagePattern":"failed to create temporary directory: %w; preserving guest synced workdir at (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":597,"sourceCode":"\t\treturn nil\n\t}\n\tstatsMsg := \"\"\n\tif stats != nil {\n\t\tif s := stats.String(); s != \"\" {\n\t\t\tstatsMsg = fmt.Sprintf(\" (%s)\", s)\n\t\t}\n\t}\n\n\tmessage := fmt.Sprintf(\"⚠️ Accept the changes?%s\", statsMsg)\n\toptions := []string{\n\t\t\"Yes\",\n\t\t\"No\",\n\t\t\"View the changed contents\",\n\t}\n\n\tbaseDir, err := os.MkdirTemp(\"\", \"lima-guest-synced-*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temporary directory: %w; preserving guest synced workdir at %s\", err, destRsyncDir)\n\t}\n\tdefer func() {\n\t\tif err := os.RemoveAll(baseDir); err != nil {\n\t\t\tlogrus.WithError(err).Warnf(\"Failed to clean up temporary directory %s\", baseDir)\n\t\t}\n\t}()\n\thostTmpDest := filepath.Join(baseDir, filepath.Base(hostCurrentDir))\n\terr = os.MkdirAll(hostTmpDest, 0o755)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temporary directory: %w; preserving guest synced workdir at %s\", err, destRsyncDir)\n\t}\n\n\trsyncToTempDir := false\n\n\tfor {\n\t\tans, err := uiutil.Select(message, options)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to open TUI: %w; preserving guest synced workdir at %s\", err, destRsyncDir)","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L579-L615","documentation":"Before showing the interactive \"Accept the changes?\" prompt, askUserForRsyncBack creates a temp directory (`os.MkdirTemp(\"\", \"lima-guest-synced-*\")`) to stage a copy of the guest files for the \"View the changed contents\" option. If the temp dir cannot be created, this error is returned and, importantly, the guest synced workdir at destRsyncDir is preserved so the user's changes are not lost.","triggerScenarios":"TUI path in `limactl shell` (tty=true) after the shell exits, when os.MkdirTemp fails: TMPDIR points to a non-existent or non-writable location, disk full on the temp filesystem, or restrictive TMPDIR permissions (e.g. sandboxed macOS/Windows environments).","commonSituations":"TMPDIR set to a path inside a container or read-only mount; /tmp filled up by build artifacts; macOS App Sandbox blocking /var/folders temp dirs; running limactl under a service account with a bogus TMPDIR.","solutions":["Free space on the filesystem holding the temp directory, or clear stale temp files.","Check/fix TMPDIR: `echo $TMPDIR` and point it to a writable directory (e.g. `export TMPDIR=/tmp`).","Recover your changes from the preserved guest workdir: `limactl shell <instance>` and copy from destRsyncDir.","Run with a non-TTY (e.g. pipe stdin) to skip the interactive prompt path entirely and sync back directly.","Verify permissions on the system temp directory (`ls -ld $TMPDIR /tmp`)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"d=\"${TMPDIR:-/tmp}\"; test -d \"$d\" && test -w \"$d\" && df --output=avail \"$d\" | tail -1 || echo \"TMPDIR $d missing, unwritable, or full\"","typeGuard":null,"tryCatchPattern":"// wrapper: ensure a healthy temp dir before limactl shell\nexport TMPDIR=$(mktemp -d -t lima-tmp-XXXX)  # or fix to a known-writable dir\nlimactl shell default","preventionTips":["Keep TMPDIR pointing at an existing, writable, non-full directory.","Watch disk usage on /tmp (or $TMPDIR) before long lima sessions.","Disable aggressive tmp-cleanup daemons for directories in active use.","Remember the error preserves guest changes — recover from destRsyncDir instead of panicking."],"tags":["temp-directory","filesystem","tui"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}