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
- Check Process::isTtySupported() before calling setTty(true) and fall back to non-TTY mode.
- Allocate a TTY in the environment: docker run -t, ssh -t, run the process in a terminal.
- 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
- Always call Process::isTtySupported() before enabling TTY.
- In Docker use -t (or -it) when the child needs a TTY; in SSH use -t to force allocation.
- Design child commands to work without a TTY in daemon/CI contexts.
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
- TTY mode is not supported on Windows platform.
- Disabling output while the process is running is not…
- Output cannot be disabled while an idle timeout is set.
- Enabling output while the process is running is not…
- This PHP has been compiled with --enable-sigchild. Term…
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)