{"record":{"id":"9b8b7bc5e0262e08","repo":"lima-vm/lima","slug":"expected-the-depth-of-the-host-working-directory","errorCode":null,"errorMessage":"expected the depth of the host working directory (%#q) to be at least %d, only got %d (Hint: %s)","messagePattern":"expected the depth of the host working directory \\(%#q\\) to be at least (.+?), only got (.+?) \\(Hint: (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":259,"sourceCode":"\n\tif err != nil {\n\t\t// An empty hostCurrentDir would reach rsync as the toolchain root.\n\t\tif syncHostWorkdir {\n\t\t\treturn fmt.Errorf(\"failed to determine the host directory to sync: %w\", err)\n\t\t}\n\t\tchangeDirCmd = \"false\"\n\t\tlogrus.WithError(err).Warn(\"failed to get the current directory\")\n\t}\n\tif syncHostWorkdir {\n\t\tif _, err := exec.LookPath(string(copytool.BackendRsync)); err != nil {\n\t\t\treturn fmt.Errorf(\"rsync is required for `--sync` but not found: %w\", err)\n\t\t}\n\n\t\t// Measure the host's own path. The form hostCurrentDir carries on Windows\n\t\t// adds one component (/c/...) or two (/cygdrive/c/...).\n\t\tsrcWdDepth := pathDepth(hostCurrentDirNative, runtime.GOOS == \"windows\")\n\t\tif srcWdDepth < rsyncMinimumSrcDirDepth {\n\t\t\treturn fmt.Errorf(\"expected the depth of the host working directory (%#q) to be at least %d, only got %d (Hint: %s)\",\n\t\t\t\thostCurrentDirNative, rsyncMinimumSrcDirDepth, srcWdDepth, \"cd to a deeper directory\")\n\t\t}\n\t\t// rsync acts on hostCurrentDir, so measure that too: cygpath can report\n\t\t// success without writing a path, and an fstab can map a deep directory\n\t\t// onto a shallow one. It is always POSIX form, even on Windows.\n\t\tif dstWdDepth := pathDepth(hostCurrentDir, false); dstWdDepth < rsyncMinimumSrcDirDepth {\n\t\t\treturn fmt.Errorf(\"expected the depth of the converted host working directory (%#q) to be at least %d, only got %d\",\n\t\t\t\thostCurrentDir, rsyncMinimumSrcDirDepth, dstWdDepth)\n\t\t}\n\t}\n\n\tvar destRsyncDir string\n\tworkDir, err := cmd.Flags().GetString(\"workdir\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif workDir != \"\" && syncHostWorkdir {\n\t\treturn errors.New(\"cannot use `--workdir` and `--sync` at the same time\")","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L241-L277","documentation":"Rsync acts on the host working directory as the transfer root, so Lima requires the path to be at least `rsyncMinimumSrcDirDepth` components deep to avoid syncing an overly broad tree (e.g. a drive or home root). When the native host path's depth (counting extra Windows components like `/c/` or `/cygdrive/c/`) is below that minimum, shellAction aborts with this error.","triggerScenarios":"Running `limactl shell <instance> --sync <dir>` where `<dir>` (or the current directory) resolves to a shallow path such as `/`, `/home`, `/Users`, or on Windows a near-root path once the drive prefix components are counted.","commonSituations":"Developers `cd` to their home directory or drive root and run `--sync`, expecting only a small folder to sync; CI jobs running from a shallow workspace root like `/work`.","solutions":["`cd` into a deeper, project-specific directory before running the command (as the error's Hint says).","Pass an explicit deeper directory to `--sync <deep/dir>` instead of relying on the cwd.","If you truly need to sync a shallow root, copy the tree into a deeper staging directory first."],"exampleFix":"# before\ncd ~ && limactl shell default --sync\n# after\ncd ~/projects/myapp && limactl shell default --sync","handlingStrategy":"validation","validationCode":"depth() { local p=\"$1\"; local n=0; while [ \"$p\" != \"/\" ]; do n=$((n+1)); p=$(dirname \"$p\"); done; echo \"$n\"; }; [ \"$(depth \"$PWD\")\" -ge 3 ] || { echo 'cd to a deeper directory'; exit 1; }","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Never run --sync from /, home, or drive roots; cd into the project first.","Use explicit deep paths with `--sync <dir>` in scripts.","Pin CI working directories to a project subdirectory, not the workspace root."],"tags":["cli","limactl","rsync","path-depth","sync"],"backgroundTag":"path-too-shallow-for-rsync","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}