lima-vm/lima · error

failed to start less: %w

Error message

failed to start less: %w

What it means

After wiring the diff output into the pager's stdin, limactl starts the pager process (lessCmd.Start()). If the pager binary cannot be launched — missing executable, PAGER pointing to a non-existent program, or exec permission problems — this error is returned and the pending rsync-back decision is abandoned with the guest workdir preserved.

Source

Thrown at cmd/limactl/shell.go:658

					rsyncToTempDir = true
				}
			}

			pagerArgs := pagerCommand()
			lessCmd := exec.CommandContext(ctx, pagerArgs[0], pagerArgs[1:]...)

			pipeIn, err := lessCmd.StdinPipe()
			if err != nil {
				return fmt.Errorf("failed to create pipe for less: %w", err)
			}
			if diffCmd != nil {
				diffCmd.Stdout = pipeIn
			}
			lessCmd.Stdout = cmd.OutOrStdout()
			lessCmd.Stderr = cmd.OutOrStderr()

			if err := lessCmd.Start(); err != nil {
				return fmt.Errorf("failed to start less: %w", err)
			}

			// Write rsync dry-run output first
			if stats != nil {
				rsyncHead := fmt.Sprintf("%s--- rsync dry-run statistics ---%s", colorGray, colorNone)
				diffHead := fmt.Sprintf("%s--- detailed diff --- %s", colorGray, colorNone)
				if diffCmd == nil {
					diffHead = fmt.Sprintf("%s--- detailed diff unavailable (`diff` not found) --- %s", colorGray, colorNone)
				}
				combinedOutput := fmt.Sprintf(
					"%s\n%s\n\n%s\n\n\n%s\n",
					rsyncHead,
					stats.String(),
					rawOutput,
					diffHead,
				)

				if _, err := fmt.Fprint(pipeIn, combinedOutput); err != nil {

View on GitHub (pinned to dd909d0973)

Solutions

  1. Fix PAGER: `export PAGER=less` or unset it to use the default `less -R`.
  2. Install the pager (`apt install less` / `brew install less`) or verify it is on PATH: `command -v less`.
  3. Skip preview at the prompt and choose Yes/No directly to complete the sync-back.
  4. Recover changes manually from destRsyncDir in the guest if the session already errored out.

Example fix

// before
export PAGER=most   # most not installed
// after
export PAGER=less   # or: unset PAGER
Defensive patterns

Strategy: validation

Validate before calling

p=$(echo "${PAGER:-less}" | awk '{print $1}'); command -v "$p" >/dev/null && echo "pager '$p' found" || echo "pager '$p' missing: install it or unset PAGER"

Try / catch

// ensure a working pager before interactive limactl use
command -v less >/dev/null || export PAGER=cat
limactl shell default

Prevention

When it happens

Trigger: Selecting "View the changed contents" when the pager from pagerCommand() (PAGER env var or `less -R`) cannot be started: PAGER set to a missing/broken binary, PATH lacking `less`, or the pager binary lacks execute permission.

Common situations: Minimal containers/VMs without `less` installed; PAGER exported as something like `most` or a script that was removed; PATH modified so standard tools aren't found; Windows environments without a less equivalent.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/f64b06ca3b6e1e63. Report an issue: GitHub.