hashicorp/nomad · error
failed to set command tty: %v
Error message
failed to set command tty: %v
What it means
After opening the pty, runTTY applies terminal settings (raw mode, window size) to the slave tty via setTTY(). If that configuration step fails, the executor wraps it as 'failed to set command tty' and the exec session fails even though the pty opened.
Source
Thrown at drivers/shared/executor/exec_utils.go:56
processWait func() (*os.ProcessState, error)
}
func (e *execHelper) run(ctx context.Context, tty bool, stream drivers.ExecTaskStream) error {
if tty {
return e.runTTY(ctx, stream)
}
return e.runNoTTY(ctx, stream)
}
func (e *execHelper) runTTY(ctx context.Context, stream drivers.ExecTaskStream) error {
ptyF, tty, err := e.newTerminal()
if err != nil {
return fmt.Errorf("failed to open a tty: %v", err)
}
defer tty.Close()
if err := e.setTTY(tty); err != nil {
return fmt.Errorf("failed to set command tty: %v", err)
}
if err := e.processStart(); err != nil {
return fmt.Errorf("failed to start command: %v", err)
}
var wg sync.WaitGroup
errCh := make(chan error, 3)
pty, err := ptyF()
if err != nil {
return fmt.Errorf("failed to get pty: %v", err)
}
defer pty.Close()
wg.Add(1)
go handleStdin(e.logger, pty, stream, errCh)
// when tty is on, stdout and stderr point to the same pty so only read once
go handleStdout(e.logger, pty, &wg, stream.Send, errCh)View on GitHub (pinned to 482b49bf1a)
Solutions
- Retry the exec session — often transient if the pty closed unexpectedly
- Check executor/logs for the underlying ioctl error and platform support
- Try non-TTY exec as a workaround
- Upgrade Nomad/executor for platform-specific termios fixes
Defensive patterns
Strategy: retry
Try / catch
if err := run(); err != nil {
if strings.Contains(err.Error(), "failed to set command tty") {
// retry once, then fall back to non-tty exec
opts.Tty = false
err = run()
}
} Prevention
- Keep executor and client versions in sync for termios fixes
- Avoid unusual TERM environments for exec sessions
- Fall back to non-TTY exec for automated tooling
When it happens
Trigger: setTTY fails — typically ioctl/termios errors applying raw mode or terminal attributes, or failure configuring the pty size on the freshly allocated tty.
Common situations: Exotic terminal types/env (TERM values) causing termios setup issues; race where the pty slave closes immediately; platform quirks in cgo termios calls; window-size ioctl failure.
Related errors
- failed to open a tty: %v
- not a terminal
- no exec command is configured
- unknown task name %q
- task %q not started yet.
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/b87089f7f7c946cb.
Report an issue: GitHub.