charmbracelet/gum · error
failed to write selected row: %w
Error message
failed to write selected row: %w
What it means
Gum table failed to write the entire selected row to the output writer (when --return-column is not used or out of range). The writer error is wrapped with %w. Like error 44, the TUI succeeded but emitting the result failed.
Source
Thrown at table/command.go:174
tea.WithOutput(os.Stderr),
tea.WithContext(ctx),
).Run()
if err != nil {
return fmt.Errorf("failed to start tea program: %w", err)
}
if tm == nil {
return fmt.Errorf("failed to get selection")
}
m = tm.(model)
if o.ReturnColumn > 0 && o.ReturnColumn <= len(m.selected) {
if err = writer.Write([]string{m.selected[o.ReturnColumn-1]}); err != nil {
return fmt.Errorf("failed to write col %d of selected row: %w", o.ReturnColumn, err)
}
} else {
if err = writer.Write([]string(m.selected)); err != nil {
return fmt.Errorf("failed to write selected row: %w", err)
}
}
writer.Flush()
return nil
}
View on GitHub (pinned to 4d089f9550)
Solutions
- Verify the command's stdout destination is open and writable for the whole run
- Don't let downstream consumers close the pipe prematurely
- Check disk space/permissions on the redirect target
- Read the wrapped %w cause for the precise IO failure
Example fix
// before gum table > /dev/full # write error: no space // after gum table > results.txt
Defensive patterns
Strategy: try-catch
Try / catch
row=$(gum table < data.csv) || { echo 'failed to write row' >&2; exit 1; } Prevention
- Don't pipe gum output into commands that exit early
- Redirect to writable files, not full devices
- Verify stdout is open in containerized/scripted environments
When it happens
Trigger: No valid `--return-column` (0, unset, or greater than selected row length), `writer.Write([]string(m.selected))` fails — broken stdout pipe, closed descriptor, or IO error.
Common situations: Downstream process exits before reading output (SIGPIPE), redirecting to an unwritable path, disk full, or containerized environments with closed stdout.
Related errors
- failed to write col %d of selected row: %w
- unable to write output: %w
- stdin is empty
- failed to read line: %w
- failed to write to stdout: %w
AI-assisted analysis of charmbracelet/gum@4d089f9550 (2026-08-31).
Data as JSON: /api/errors/cffdb3b13b57d5a0.
Report an issue: GitHub.