lima-vm/lima · error

failed to sync back the changes from guest instance to host

Error message

failed to sync back the changes from guest instance to host temporary directory: %w

What it means

When the user chooses "View the changed contents", limactl first rsyncs the guest workdir into the temporary staging directory so `diff` can compare it against the host directory. This error wraps a failure of that guest->temp-dir rsync. The guest synced workdir is preserved because cleanup only happens after a successful sync-back decision.

Source

Thrown at cmd/limactl/shell.go:638

			return rsyncBack()
		case 1: // No
			cleanupGuestWorkdir = true
			logrus.Info("Skipping syncing back the changes to host.")
			return nil
		case 2: // View the changed contents
			var diffCmd *exec.Cmd
			if _, err := exec.LookPath("diff"); err != nil {
				logrus.WithError(err).Warn("`diff` not found; showing rsync dry-run output only")
			} else {
				diffCmd = exec.CommandContext(ctx, "diff", "-ruN", "--color=always", hostCurrentDir, hostTmpDest)
				if !rsyncToTempDir {
					paths := []string{
						remoteSource,
						hostTmpDest,
					}

					if err := rsyncDirectory(ctx, cmd, rsync, paths); err != nil {
						return fmt.Errorf("failed to sync back the changes from guest instance to host temporary directory: %w", err)
					}
					rsyncToTempDir = true
				}
			}

			pagerArgs := pagerCommand()
			lessCmd := exec.CommandContext(ctx, pagerArgs[0], pagerArgs[1:]...)

			pipeIn, err := lessCmd.StdinPipe()
			if err != nil {
				return fmt.Errorf("failed to create pipe for less: %w", err)
			}
			if diffCmd != nil {
				diffCmd.Stdout = pipeIn
			}
			lessCmd.Stdout = cmd.OutOrStdout()
			lessCmd.Stderr = cmd.OutOrStderr()

View on GitHub (pinned to dd909d0973)

Solutions

  1. Choose "Yes" at the prompt to sync back directly (or rerun and accept), bypassing the diff staging step.
  2. Verify the instance is still RUNNING (`limactl list`) — if it was stopped, restart it and manually copy files from destRsyncDir.
  3. Free space on the temp filesystem and retry.
  4. Inspect the wrapped rsync stderr printed by rsyncDirectory for the root cause.
  5. Fall back to manual recovery: `limactl shell <instance> rsync -av <destRsyncDir>/ .` from within the guest or scp from `instance:destRsyncDir`.
Defensive patterns

Strategy: fallback

Validate before calling

limactl list | grep -q 'RUNNING' && df --output=avail "${TMPDIR:-/tmp}" | tail -1 || echo 'instance stopped or temp fs full: preview unavailable'

Try / catch

// on preview failure, fall back to direct sync-back decision
limactl shell default || limactl shell default < /dev/null   # non-tty run syncs back unconditionally

Prevention

When it happens

Trigger: Selecting "View the changed contents" in the post-shell prompt, and rsyncDirectory from `instance:destRsyncDir` to hostTmpDest fails: SSH connection dropped after a long shell session, large change set exceeding disk space in temp, or rsync/ssh binary problems.

Common situations: Long-running shell sessions whose SSH control master expired; guest VM stopped while the prompt was pending; temp filesystem too small for a big workdir; rsync interrupted by Ctrl-C during transfer.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/b30fa516aaead606. Report an issue: GitHub.