{"record":{"id":"c3b43c69b06db5d2","repo":"lima-vm/lima","slug":"failed-to-run-diff-command-w","errorCode":null,"errorMessage":"failed to run diff command: %w","messagePattern":"failed to run diff command: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":688,"sourceCode":"\t\t\t\t\trsyncHead,\n\t\t\t\t\tstats.String(),\n\t\t\t\t\trawOutput,\n\t\t\t\t\tdiffHead,\n\t\t\t\t)\n\n\t\t\t\tif _, err := fmt.Fprint(pipeIn, combinedOutput); err != nil {\n\t\t\t\t\t_ = pipeIn.Close()\n\t\t\t\t\treturn fmt.Errorf(\"failed to write rsync stats to pager: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif diffCmd != nil {\n\t\t\t\tif err := diffCmd.Run(); err != nil {\n\t\t\t\t\t// Command `diff` returns exit code 1 when files differ.\n\t\t\t\t\tvar exitErr *exec.ExitError\n\t\t\t\t\tif errors.As(err, &exitErr) && exitErr.ExitCode() >= 2 {\n\t\t\t\t\t\t_ = pipeIn.Close()\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to run diff command: %w\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_ = pipeIn.Close()\n\n\t\t\tif err := lessCmd.Wait(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to wait for less command: %w\", err)\n\t\t\t}\n\t\t}\n\t}\n}\n\n// pagerCommand returns the pager command and arguments to use for viewing colored diff output.\nfunc pagerCommand() []string {\n\tpager := strings.TrimSpace(os.Getenv(\"PAGER\"))\n\tif pager == \"\" {\n\t\treturn []string{\"less\", \"-R\"}","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L670-L706","documentation":"The preview runs `diff -ruN --color=always <hostCurrentDir> <hostTmpDest>` piped into the pager. `diff` exiting 1 just means files differ (expected, tolerated), but exit code >= 2 signals a real diff failure (unreadable files, missing directories, diff internal error). limactl surfaces that as this error, with the guest workdir preserved.","triggerScenarios":"Selecting \"View the changed contents\" when the diff process exits with code 2+: a file exists in one tree but is unreadable due to permissions, the host directory or temp staging dir disappeared mid-diff, symlink loops, or corrupted special files causing diff to abort.","commonSituations":"Host directory contains root-owned or 0600 files owned by another user; the host dir was deleted while the prompt was open; a concurrently-running process removes temp staging files mid-diff; very deep/odd file trees hitting diff limits.","solutions":["Fix read permissions on the host directory contents (`chmod -R u+r`, or run as a user who can read them), then retry the preview.","Confirm hostCurrentDir still exists and is accessible; recreate it if it was deleted, then choose \"Yes\" to sync back.","Skip the preview and choose \"Yes\"/\"No\" at the prompt — sync-back does not require diff.","Inspect the wrapped error output to identify the specific unreadable path reported by diff.","Recover changes manually from destRsyncDir in the guest if the session cannot proceed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"find . ! -readable -print -quit | grep -q . && echo 'unreadable files present: diff preview will fail (exit >= 2)' || echo 'all files readable, diff preview should work'","typeGuard":null,"tryCatchPattern":"// prefer answering the prompt directly over debugging diff\n// diff exit 1 (files differ) is normal and NOT an error; only >= 2 aborts\nlimactl shell default","preventionTips":["Keep all files in synced workdirs readable by your user (avoid root-owned files from sudo-inside-guest).","Don't delete host or temp directories while the preview prompt is open.","Remember diff exit code 1 is expected when files differ — only >= 2 is a failure.","Skip preview for workdirs with exotic file types (sockets, symlink loops)."],"tags":["diff","permissions","preview"],"backgroundTag":"diff-command-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}