{"record":{"id":"7bb5c6377214dd13","repo":"lima-vm/lima","slug":"failed-to-wait-for-less-command-w","errorCode":null,"errorMessage":"failed to wait for less command: %w","messagePattern":"failed to wait for less command: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/shell.go","lineNumber":696,"sourceCode":"\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\"}\n\t}\n\targs := strings.Fields(pager)\n\tif filepath.Base(args[0]) != \"less\" {\n\t\treturn args\n\t}\n\tif lessHasRawColorFlag(args[1:]) {\n\t\treturn args\n\t}","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/shell.go#L678-L714","documentation":"limactl's shell/preview flow pipes diff output through a `less` pager (returned by pagerCommand) and returns this error when lessCmd.Wait() reports a non-zero exit. It means the pager process itself failed or was terminated abnormally, not that the rsync diff content was bad. It is thrown in askUserForRsyncBack, which shows the user a colored diff of files to sync and asks whether to proceed.","triggerScenarios":"Running `limactl shell <inst> <cmd>` (shellAction) into a path where askUserForRsyncBack displays a diff in the `less` pager and the pager exits non-zero: user presses q mid-session in some less versions configured to exit with error, terminal closed while pager active, or the resolved $PAGER/less binary is broken or missing required terminal support.","commonSituations":"PAGER set to a non-pager command or a wrapper script that fails; running inside environments with no/wrong TERM (cron, CI, minimal containers) where less can't initialize; user quitting less with an error exit code; broken LESSOPEN filter scripts.","solutions":["Check $PAGER and $LESS environment variables for invalid settings and unset or fix them","Re-run the command with the pager disabled (e.g. PAGER=cat or GIT_PAGER=cat equivalent) to bypass `less`","Verify `less` is installed and works: run `echo test | less` and confirm normal exit","Ensure the terminal is a real TTY with a valid TERM setting; avoid invoking interactive limactl shell from non-interactive CI jobs"],"exampleFix":"// before: PAGER=/usr/bin/less -FX with broken -X in old less\n// after\nexport PAGER=less   # or unset PAGER to use the default","handlingStrategy":"fallback","validationCode":"if ! command -v less >/dev/null 2>&1; then echo 'less missing; set PAGER=cat' >&2; fi\necho probe | less -F >/dev/null 2>&1 || export PAGER=cat","typeGuard":null,"tryCatchPattern":"if ! limactl shell default true; then\n  export PAGER=cat\n  limactl shell default <cmd> || exit $?\nfi","preventionTips":["Keep PAGER unset or a simple, tested pager in automation","Only run interactive limactl shell commands from a real TTY","Test `less` works in the target environment before scripting"],"tags":["pager","cli","terminal"],"backgroundTag":"pager-exited-nonzero","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}