abiosoft/colima · warning

error getting terminal size

Error message

error getting terminal size: %w

What it means

verboseWriter.updateTerm (util/terminal/output.go:151) queries the terminal size via term.GetSize(os.Stdout.Fd()), throttled to once per 2 seconds; the wrapped error is almost always ENOTTY because stdout is not a terminal. printScreen (output.go:121) propagates the error, so the verbose live-view renderer aborts instead of drawing. A width<=0 case is already defended separately (falls back to 80), so the error path is specifically the ioctl failure.

Solutions

  1. Run the command directly in an interactive terminal instead of piping
  2. When piping is required, allocate a pty: `script -q /dev/null colima start ... | tee log.txt`
  3. Inspect colima's own logs instead of stdout (e.g. `colima start --verbose` writes to log files under ~/.colima / ~/Library/Logs/colima)
  4. If you embed this writer in your own tool, treat the updateTerm error as non-fatal and keep a default width of 80

Example fix

// before
out := v.printScreen() // returns error when stdout is piped, screen never renders

// after
if err := v.printScreen(); err != nil {
    // non-tty stdout: fall back to plain printing, don't kill the writer
    v.termWidth = 80
}
Defensive patterns

Strategy: fallback

Validate before calling

// detect non-tty stdout before enabling the live verbose writer
func stdoutIsTTY() bool {
    return term.IsTerminal(int(os.Stdout.Fd()))
}

Try / catch

if err := v.printScreen(); err != nil {
    // treat terminal-size failure as cosmetic: fall back to width 80 and keep running
    v.termWidth = 80
}

Prevention

When it happens

Trigger: Running colima with verbose/live output piped or redirected: `colima start --verbose | tee log.txt`, `colima start > out.log`, or colima invoked from CI/daemon contexts where stdout has no controlling terminal.

Common situations: Piping colima output for logging in scripts; running colima in CI jobs; capturing output with subprocess pipes; terminal multiplexers that detach the pty mid-run.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/220c0d234d502372. Report an issue: GitHub.

Appendix: source

Thrown at util/terminal/output.go:151

}

func (v *verboseWriter) clearScreen() {
	for i := 0; i < v.screenHeight; i++ {
		ClearLine()
	}
	v.screenHeight = 0
}

func (v *verboseWriter) updateTerm() error {
	// no need to refresh so quickly
	if time.Since(v.lastUpdate) < time.Second*2 {
		return nil
	}
	v.lastUpdate = time.Now().UTC()

	w, _, err := term.GetSize(int(os.Stdout.Fd()))
	if err != nil {
		return fmt.Errorf("error getting terminal size: %w", err)
	}
	// A width of zero would result in a division by zero panic when computing overflow
	// in printScreen. Therefore, set it to a safe - even though probably wrong - value.
	// We use <= 0 here because negative values are guaranteed to lead to unexpected
	// results, even if they don't cause panics.
	if w <= 0 {
		w = 80
	}
	v.termWidth = w

	return nil
}

func countDisplayLines(line string, termWidth int) int {
	if termWidth <= 0 {
		termWidth = 80
	}

View on GitHub (pinned to c3a5f9184d)