{"record":{"id":"bcb540690083b218","repo":"lima-vm/lima","slug":"failed-to-create-the-synced-workdir-in-guest-insta","errorCode":null,"errorMessage":"failed to create the synced workdir in guest instance: %w","messagePattern":"failed to create the synced workdir in guest instance: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":430,"sourceCode":"\t\t// Only remove these options when writing the SSH config file and executing `limactl shell`, since multiplexing seems to work with port forwarding.\n\t\tsshOpts = sshutil.SSHOptsRemovingControlPath(sshOpts)\n\t}\n\tsshArgs := append([]string{}, sshExe.Args...)\n\tsshArgs = append(sshArgs, sshutil.SSHArgsFromOpts(sshOpts)...)\n\n\tvar (\n\t\tsshExecForRsync *exec.Cmd\n\t\trsync           copytool.CopyTool\n\t)\n\tif syncHostWorkdir {\n\t\tlogrus.Infof(\"Syncing host current directory(%s) to guest instance...\", hostCurrentDir)\n\t\tsshExecForRsync = exec.CommandContext(ctx, sshExe.Exe, sshArgs...)\n\n\t\t// Create the destination directory in the guest instance,\n\t\t// we could have done this by using `--rsync-path` but it's more\n\t\t// complex to quote properly.\n\t\tif err := executeSSHForRsync(ctx, *sshExecForRsync, inst.SSHLocalPort, inst.SSHAddress, fmt.Sprintf(\"mkdir -p %s\", shellescape.Quote(destRsyncDir))); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create the synced workdir in guest instance: %w\", err)\n\t\t}\n\n\t\t// Quote the destination path for rsync versions before 3.2.4, where --protect-args is not the default\n\t\t// and the remote shell would split paths containing spaces.\n\t\trsyncVer, err := rsyncVersion(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get rsync version: %w\", err)\n\t\t}\n\t\tif rsyncVer.LessThan(*semver.New(\"3.2.4\")) {\n\t\t\tdestRsyncDir = shellescape.Quote(destRsyncDir)\n\t\t}\n\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,","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L412-L448","documentation":"With `--sync`, Lima first creates the destination directory inside the guest (`mkdir -p <destRsyncDir>`) over SSH before invoking rsync — quoting via `--rsync-path` is deliberately avoided as harder to get right. If that SSH command fails (connection problem, authentication failure, remote mkdir error), the error is wrapped with this message.","triggerScenarios":"`--sync` is active and `executeSSHForRsync` runs `mkdir -p <destRsyncDir>` at the instance's SSHLocalPort/SSHAddress, and the SSH execution fails: instance not running, port forwarding broken, permission denied creating the directory under the guest user's home.","commonSituations":"Instance stopped or crashed between `limactl start` and the shell command; SSH daemon not ready yet; guest disk full or home directory read-only making `mkdir -p` fail; wrong SSH port after a port conflict.","solutions":["Confirm the instance is running (`limactl list`) and start it with `limactl start <instance>` if not.","Retry after a moment if the guest was just booted (SSH daemon may not be ready).","Check guest home permissions/disk space (`limactl shell <instance> df -h; ls -ld ~`) and fix mkdir failures.","Run with `--debug` to inspect the underlying SSH error for connection/auth specifics."],"exampleFix":"# before\nlimactl shell stopped-instance --sync .\n# after\nlimactl start stopped-instance\nlimactl shell stopped-instance --sync .","handlingStrategy":"retry","validationCode":"limactl list | grep -q \"^$inst.*Running\" || { echo 'instance not running'; exit 1; }","typeGuard":"null","tryCatchPattern":"for i in 1 2 3; do limactl shell \"$inst\" --sync . && break; sleep $((i*5)); done","preventionTips":["Ensure the instance is Running before issuing --sync shell commands.","After booting, wait for SSH readiness (limactl start blocks until ready; avoid racing manual starts).","Check guest home writability and free disk space periodically.","Wrap sync commands in a short retry loop for transient SSH failures."],"tags":["cli","limactl","ssh","rsync","sync"],"backgroundTag":"ssh-command-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}