{"record":{"id":"8f7efd56b58d8ad2","repo":"lima-vm/lima","slug":"failed-to-rsync-to-the-guest-w","errorCode":null,"errorMessage":"failed to rsync to the guest %w","messagePattern":"failed to rsync to the guest %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":460,"sourceCode":"\n\t\tpaths := []string{\n\t\t\thostCurrentDir,\n\t\t\tfmt.Sprintf(\"%s:%s\", inst.Name, destRsyncDir),\n\t\t}\n\t\trsync, err = copytool.New(ctx, string(copytool.BackendRsync), paths, &copytool.Options{\n\t\t\tRecursive: true,\n\t\t\tVerbose:   false,\n\t\t\tAdditionalArgs: []string{\n\t\t\t\t\"--delete\",\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlogrus.Debugf(\"using copy tool %#q\", rsync.Name())\n\n\t\tif err := rsyncDirectory(ctx, cmd, rsync, paths); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to rsync to the guest %w\", err)\n\t\t}\n\t\tlogrus.Infof(\"Successfully synced host current directory to guest(%s) instance.\", destRsyncDir)\n\t}\n\n\tif isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {\n\t\t// required for showing the shell prompt: https://stackoverflow.com/a/626574\n\t\tsshArgs = append(sshArgs, \"-t\")\n\t}\n\tif _, present := os.LookupEnv(\"COLORTERM\"); present {\n\t\t// SendEnv config is cumulative, with already existing options in ssh_config\n\t\tsshArgs = append(sshArgs, \"-o\", \"SendEnv=COLORTERM\")\n\t}\n\tlogLevel := \"ERROR\"\n\t// For versions older than OpenSSH 8.9p, LogLevel=QUIET was needed to\n\t// avoid the \"Shared connection to 127.0.0.1 closed.\" message with -t.\n\tolderSSH := sshutil.DetectOpenSSHVersion(ctx, sshExe).LessThan(*semver.New(\"8.9.0\"))\n\tif olderSSH {\n\t\tlogLevel = \"QUIET\"","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L442-L478","documentation":"limactl shell wraps the host-side rsync of the current working directory into the guest's synced workdir. This error is produced when the `rsyncDirectory` invocation (via the configured copy tool over SSH to `inst.Name`) exits non-zero. It means the initial host->guest directory sync failed, so the shell session is aborted before starting so the user doesn't work against stale or empty files in the guest.","triggerScenarios":"Running `limactl shell <instance>` (or `limactl start --sync-host-workdir` style flows) with syncHostWorkdir enabled, when the rsync child process from hostCurrentDir to `instance:destRsyncDir` fails: rsync binary missing or too old, SSH connection refused, permission denied on destRsyncDir, or path quoting issues (paths with spaces on rsync < 3.2.4).","commonSituations":"The guest VM was just started and sshd is not yet reachable; the rsync installed is older than 3.2.4 and the current directory path contains spaces or special characters; the host directory contains files the guest user cannot write (root-owned dirs); disk full in the guest; the instance was stopped between the mkdir and the rsync.","solutions":["Re-run the command; if the VM was still booting, wait until `limactl list` shows the instance RUNNING and sshd is up.","Verify rsync exists on the host and guest (`rsync --version`) and is >= 3.2.4, or avoid spaces/special chars in the host directory path.","Check the guest workdir permissions: `limactl shell <instance> ls -ld <destRsyncDir>` and fix ownership/permissions.","Inspect the wrapped error (rsync stderr is shown by rsyncDirectory) for the underlying cause (connection refused, auth failure, disk full).","If syncing is not needed, disable host workdir syncing for this invocation."],"exampleFix":"// before\nif err := rsyncDirectory(ctx, cmd, rsync, paths); err != nil {\n    return fmt.Errorf(\"failed to rsync to the guest %w\", err)\n}\n// after (retry once if the VM was still settling)\nif err := rsyncDirectory(ctx, cmd, rsync, paths); err != nil {\n    time.Sleep(2 * time.Second)\n    if err := rsyncDirectory(ctx, cmd, rsync, paths); err != nil {\n        return fmt.Errorf(\"failed to rsync to the guest: %w\", err)\n    }\n}","handlingStrategy":"retry","validationCode":"limactl list | grep -q 'RUNNING' && command -v rsync >/dev/null && rsync --version | awk 'NR==1{print $3}' || echo 'instance not running or rsync missing'","typeGuard":null,"tryCatchPattern":"// bash wrapper around limactl shell\nfor i in 1 2 3; do\n  if limactl shell default; then break; fi\n  sleep $((i * 2))\ndone","preventionTips":["Wait for the instance to be RUNNING before running limactl shell (poll `limactl list`).","Keep rsync >= 3.2.4 on the host to avoid protect-args/quoting issues with spaces in paths.","Avoid working from directories with spaces or exotic characters when using workdir sync.","Ensure the guest user has write access to the synced workdir location."],"tags":["rsync","ssh","vm","file-sync"],"backgroundTag":"rsync-transfer-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}