Skip to content

fix: machine init/add fall back to plain output when stdout isn't a TTY (#386)#395

Open
joeblew999 wants to merge 1 commit into
psviderski:mainfrom
joeblew999:fix/headless-init-no-tty
Open

fix: machine init/add fall back to plain output when stdout isn't a TTY (#386)#395
joeblew999 wants to merge 1 commit into
psviderski:mainfrom
joeblew999:fix/headless-init-no-tty

Conversation

@joeblew999

Copy link
Copy Markdown

Fixes #386.

uc machine init and uc machine add use huh readiness spinners that open /dev/tty, so they die in shells with no controlling terminal (CI, SSH automation, task runners) even with -y. Today the only workaround is wrapping the command in a PTY (script -q /dev/null …), which also swallows the real error on failure.

This guards both spinners with tui.IsStdoutTerminal() and falls back to a plain log + direct wait when stdout isn't a terminal — the exact pattern connectClusterWithProgress already uses. Headless now works without a PTY, and errors surface normally.

  • cmd/uncloud/machine/init.go — "Waiting for the cluster to be ready..."
  • cmd/uncloud/machine/add.go — "Waiting for the machine to join the cluster..."

No behaviour change in a terminal (spinner as before).

…a TTY

The readiness spinners (huh) open /dev/tty, so 'uc machine init/add' died headless
(CI, SSH, mise) — we had to wrap it in a PTY (script -q /dev/null), which swallowed
errors. Guard both spinners with tui.IsStdoutTerminal() (the pattern connect.go
already uses); headless gets a plain log + the real error. Upstreamable: psviderski#386.
@miekg

miekg commented Jun 7, 2026 via email

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uc machine init requires a TTY in non-interactive shells (could not open TTY)

2 participants