{"record":{"id":"87633a174366fb75","repo":"lima-vm/lima","slug":"failed-to-parse-rsync-version","errorCode":null,"errorMessage":"failed to parse rsync version","messagePattern":"failed to parse rsync version","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":812,"sourceCode":"\t// and `\\\\server\\share\\` both reach here. Trim one that leaves a separator\n\t// behind, which spares the bare roots \"/\" and `C:\\`.\n\tif trimmed := strings.TrimSuffix(slashed, \"/\"); strings.Contains(trimmed, \"/\") {\n\t\tslashed = trimmed\n\t}\n\treturn strings.Count(slashed, \"/\") + 1\n}\n\nfunc rsyncVersion(ctx context.Context) (*semver.Version, error) {\n\tout, err := exec.CommandContext(ctx, string(copytool.BackendRsync), \"--version\").Output()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// `rsync  version 3.2.7  protocol version 31`\n\tre := regexp.MustCompile(`version (\\d+\\.\\d+\\.\\d+)`)\n\tmatches := re.FindSubmatch(out)\n\tif len(matches) < 2 {\n\t\treturn nil, errors.New(\"failed to parse rsync version\")\n\t}\n\treturn semver.NewVersion(string(matches[1]))\n}\n\n// Syncs a directory from host to guest and vice-versa. It creates a directory in the guest's home directory and copies the contents of the host's\n// current working directory into it. The guest directory paths should be prefixed with `<InstanceName>:` followed by the path.\nfunc rsyncDirectory(ctx context.Context, cmd *cobra.Command, rsync copytool.CopyTool, paths []string) error {\n\trsyncCmd, err := rsync.Command(ctx, paths, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\trsyncCmd.Stdout = cmd.OutOrStdout()\n\trsyncCmd.Stderr = cmd.OutOrStderr()\n\tlogrus.Debugf(\"executing rsync: %+v\", rsyncCmd.Args)\n\treturn rsyncCmd.Run()\n}\n\nfunc mountDirFromWindowsDir(ctx context.Context, inst *limatype.Instance, dir string) (string, error) {","sourceCodeStart":794,"sourceCodeEnd":830,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L794-L830","documentation":"rsyncVersion parses the output of the host `rsync --version` with the regex `version (\\d+\\.\\d+\\.\\d+)` to build a semver. When the output does not contain a recognizable x.y.z version string, it returns \"failed to parse rsync version\". This guards the rsync-based host<->guest directory sync feature against incompatible or unexpected rsync binaries.","triggerScenarios":"shellAction triggers askUserForRsyncBack/rsyncVersion; `rsync --version` output lacks `version <semver>` — e.g. a shell alias/shim intercepting rsync, a wrapper script printing banners, a very old rsync with different version formatting, or an unexpected string on stdout.","commonSituations":"Rsync replaced by a fake/stub binary (e.g. Homebrew shim, docker in PATH, busybox variant); patched distro builds changing the banner format; PATH shadowing by a wrapper that emits extra output before the version line; rsync not actually installed and error output being parsed.","solutions":["Run `rsync --version` manually and confirm it prints `rsync  version x.y.z`","Check PATH for shadowing: `which -a rsync` and remove/reorder wrappers or shims","Install a standard rsync build (distro package or Homebrew) if missing or nonstandard","If using a wrapper, make it pass through `--version` output unchanged"],"exampleFix":"// before: PATH starts with a dir containing an rsync stub script\n// after\nexport PATH=/usr/bin:/bin:$PATH   # or remove the stub so real rsync is found","handlingStrategy":"validation","validationCode":"out=$(rsync --version 2>&1 | head -n1) || true\necho \"$out\" | grep -Eq 'version [0-9]+\\.[0-9]+\\.[0-9]+' || echo \"unexpected rsync at $(command -v rsync): $out\" >&2","typeGuard":null,"tryCatchPattern":"if ! limactl shell default true 2>&1 | grep -q 'failed to parse rsync version'; then\n  :\nelse\n  echo 'Fix rsync install/PATH and retry' >&2; exit 1\nfi","preventionTips":["Pin a standard distro/Homebrew rsync and avoid PATH shims","Verify `rsync --version` output after toolchain changes","Don't wrap rsync with banner-printing wrapper scripts"],"tags":["rsync","version-parsing","cli"],"backgroundTag":"version-parse-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}