charmbracelet/gum · error

unable to run action: %w

Error message

unable to run action: %w

What it means

Gum spin wraps errors from tea.Program.Run() for its spinner/action model. It indicates the bubbletea spinner program failed to start or crashed while the wrapped action command ran. Because spin also redirects output to stderr and nil input, environment problems surface here.

Source

Thrown at spin/command.go:47

		align:      o.Align,
		showStdout: (o.ShowOutput || o.ShowStdout) && isOutTTY,
		showStderr: (o.ShowOutput || o.ShowStderr) && isErrTTY,
		showError:  o.ShowError,
		isTTY:      isErrTTY,
		padding:    []int{top, right, bottom, left},
	}

	ctx, cancel := timeout.Context(o.Timeout)
	defer cancel()

	tm, err := tea.NewProgram(
		m,
		tea.WithOutput(os.Stderr),
		tea.WithContext(ctx),
		tea.WithInput(nil),
	).Run()
	if err != nil {
		return fmt.Errorf("unable to run action: %w", err)
	}

	m = tm.(model)
	// If the command succeeds, and we are printing output and we are in a TTY then push the STDOUT we got to the actual
	// STDOUT for piping or other things.
	//nolint:nestif
	if m.err != nil {
		if _, err := fmt.Fprintf(os.Stderr, "%s\n", m.err.Error()); err != nil {
			return fmt.Errorf("failed to write to stdout: %w", err)
		}
		return exit.ErrExit(1)
	} else if m.status == 0 {
		var output string
		if o.ShowOutput || (o.ShowStdout && o.ShowStderr) {
			output = m.output
		} else if o.ShowStdout {
			output = m.stdout
		} else if o.ShowStderr {

View on GitHub (pinned to 4d089f9550)

Solutions

  1. Run gum spin in an interactive TTY session.
  2. Check the wrapped error for the root bubbletea cause.
  3. Ensure the parent context is not cancelled early (signals, timeouts).
  4. If automating, drop the spinner and run the command directly.

Example fix

// before (scripting in CI)
gum spin -- make test
// after
make test
Defensive patterns

Strategy: fallback

Validate before calling

if [ -t 1 ]; then gum spin -- make test; else make test; fi

Try / catch

if ! gum spin -- ./build.sh; then echo "spin or action failed" >&2; exit 1; fi

Prevention

When it happens

Trigger: `gum spin -- <command>` in a non-TTY environment, terminal init failure, or ctx cancellation (tea.WithContext) killing the program while the action runs.

Common situations: CI/cron invoking gum spin; piping stdin in a way that conflicts with tea.WithInput(nil); terminal lacking required capabilities.

Related errors


AI-assisted analysis of charmbracelet/gum@4d089f9550 (2026-08-31). Data as JSON: /api/errors/fcce8696fd8a1c42. Report an issue: GitHub.