lima-vm/lima · error
failed to create pipe for less: %w
Error message
failed to create pipe for less: %w
What it means
To display the change preview, limactl pipes `diff` output into the user's pager (usually `less`) via an os/exec StdinPipe. This error is returned when creating that pipe fails, which is rare and typically indicates process-resource exhaustion or an exec plumbing problem.
Source
Thrown at cmd/limactl/shell.go:649
if !rsyncToTempDir {
paths := []string{
remoteSource,
hostTmpDest,
}
if err := rsyncDirectory(ctx, cmd, rsync, paths); err != nil {
return fmt.Errorf("failed to sync back the changes from guest instance to host temporary directory: %w", err)
}
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)
}View on GitHub (pinned to dd909d0973)
Solutions
- Check and raise the file descriptor limit: `ulimit -n` (raise via `ulimit -n 4096` or limits.conf).
- Close leaked FDs in the parent environment or restart the shell session to release resources.
- Skip the preview: choose "Yes" or "No" at the prompt instead of "View the changed contents".
- Retry the command after freeing system resources.
Defensive patterns
Strategy: validation
Validate before calling
ulimit -n | awk '{exit ($1 < 1024 ? 1 : 0)}' && echo 'fd limit OK' || echo 'raise ulimit -n before running limactl shell' Try / catch
// pre-flight: raise soft fd limit if low ulimit -n 4096 2>/dev/null || true limactl shell default
Prevention
- Raise RLIMIT_NOFILE if you run many fd-heavy workloads.
- Avoid leaking file descriptors in wrapper scripts around limactl.
- Choose Yes/No at the prompt if preview infrastructure is constrained.
- Restart stale shells/sessions to release resources.
When it happens
Trigger: Choosing "View the changed contents" in the TTY prompt, when lessCmd.StdinPipe() returns an error: file-descriptor exhaustion (too many open FDs/ulimit -n reached), fork/exec resource limits, or the process is in a constrained sandbox.
Common situations: Shell sessions with very high open-FD counts (many sockets/files); containers with low RLIMIT_NOFILE; heavily constrained CI runners; PAGER pointed at a wrapper that closes fds unpredictably (less likely, since the pipe is created before exec).
Related errors
- failed to start less: %w
- failed to write rsync stats to pager: %w
- failed to wait for less command: %w
- failed to run %#q on %#q: %#q: %w
- failed to run %v: %#q: %w
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/fe7f48aafff4267c.
Report an issue: GitHub.