lima-vm/lima · error
failed to create temporary directory: %w; preserving guest s
Error message
failed to create temporary directory: %w; preserving guest synced workdir at %s
What it means
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.
Source
Thrown at cmd/limactl/shell.go:597
return nil
}
statsMsg := ""
if stats != nil {
if s := stats.String(); s != "" {
statsMsg = fmt.Sprintf(" (%s)", s)
}
}
message := fmt.Sprintf("⚠️ Accept the changes?%s", statsMsg)
options := []string{
"Yes",
"No",
"View the changed contents",
}
baseDir, err := os.MkdirTemp("", "lima-guest-synced-*")
if err != nil {
return fmt.Errorf("failed to create temporary directory: %w; preserving guest synced workdir at %s", err, destRsyncDir)
}
defer func() {
if err := os.RemoveAll(baseDir); err != nil {
logrus.WithError(err).Warnf("Failed to clean up temporary directory %s", baseDir)
}
}()
hostTmpDest := filepath.Join(baseDir, filepath.Base(hostCurrentDir))
err = os.MkdirAll(hostTmpDest, 0o755)
if err != nil {
return fmt.Errorf("failed to create temporary directory: %w; preserving guest synced workdir at %s", err, destRsyncDir)
}
rsyncToTempDir := false
for {
ans, err := uiutil.Select(message, options)
if err != nil {
return fmt.Errorf("failed to open TUI: %w; preserving guest synced workdir at %s", err, destRsyncDir)View on GitHub (pinned to dd909d0973)
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`).
Defensive patterns
Strategy: validation
Validate before calling
d="${TMPDIR:-/tmp}"; test -d "$d" && test -w "$d" && df --output=avail "$d" | tail -1 || echo "TMPDIR $d missing, unwritable, or full" Try / catch
// wrapper: ensure a healthy temp dir before limactl shell export TMPDIR=$(mktemp -d -t lima-tmp-XXXX) # or fix to a known-writable dir limactl shell default
Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- failed to create temp file: %w
- failed to write temp plist: %w
- failed to register instance %#q to start at login: %w
- failed to unregister instance %#q from start at login: %w
- instance %#q directory %#q exists but its %#q could not be r
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/15ea3bb49e1c8e8a.
Report an issue: GitHub.