symfony/process · error · RuntimeException

TTY mode requires /dev/tty to be read/writable.

Error message

TTY mode requires /dev/tty to be read/writable.

What it means

setTty(true) throws this RuntimeException on non-Windows platforms when the current environment cannot provide a readable/writable /dev/tty. isTtySupported() checks this at runtime; without a controlling terminal, TTY mode cannot be established.

Solutions

  1. Check Process::isTtySupported() before calling setTty(true) and fall back to non-TTY mode.
  2. Allocate a TTY in the environment: docker run -t, ssh -t, run the process in a terminal.
  3. Drop TTY mode and handle interactivity via setInput()/proc pipes instead.

Example fix

// before
$process->setTty(true); // RuntimeException without /dev/tty

// after
if (\Symfony\Component\Process\Process::isTtySupported()) {
    $process->setTty(true);
}
Defensive patterns

Strategy: fallback

Validate before calling

$ttyOk = \Symfony\Component\Process\Process::isTtySupported();
if ($ttyOk) {
    $process->setTty(true);
}

Try / catch

try {
    $process->setTty(true);
} catch (\RuntimeException $e) {
    // no /dev/tty: fall back to piped I/O
}

Prevention

When it happens

Trigger: Calling setTty(true) where /dev/tty is absent or not readable/writable — e.g., inside daemons, cron jobs, Docker containers without -t, or SSH non-interactive sessions without a TTY allocation.

Common situations: Running interactive commands in Docker (docker exec / docker run without -t); background services (systemd, supervisord) spawning subprocesses with tty enabled; CI pipelines that detach TTYs.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of symfony/process@99b85026db (2026-09-14). Data as JSON: /api/errors/1c98c4f477d1f0ee. Report an issue: GitHub.

Appendix: source

Thrown at Process.php:1087

        return $this;
    }

    /**
     * Enables or disables the TTY mode.
     *
     * @return $this
     *
     * @throws RuntimeException In case the TTY mode is not supported
     */
    public function setTty(bool $tty): static
    {
        if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
            throw new RuntimeException('TTY mode is not supported on Windows platform.');
        }

        if ($tty && !self::isTtySupported()) {
            throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
        }

        $this->tty = $tty;

        return $this;
    }

    /**
     * Checks if the TTY mode is enabled.
     */
    public function isTty(): bool
    {
        return $this->tty;
    }

    /**
     * Sets PTY mode.
     *

View on GitHub (pinned to 99b85026db)