{"record":{"id":"1c98c4f477d1f0ee","repo":"symfony/process","slug":"tty-mode-requires-dev-tty-to-be-read-writable","errorCode":null,"errorMessage":"TTY mode requires /dev/tty to be read/writable.","messagePattern":"TTY mode requires /dev/tty to be read/writable\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Process.php","lineNumber":1087,"sourceCode":"\n        return $this;\n    }\n\n    /**\n     * Enables or disables the TTY mode.\n     *\n     * @return $this\n     *\n     * @throws RuntimeException In case the TTY mode is not supported\n     */\n    public function setTty(bool $tty): static\n    {\n        if ('\\\\' === \\DIRECTORY_SEPARATOR && $tty) {\n            throw new RuntimeException('TTY mode is not supported on Windows platform.');\n        }\n\n        if ($tty && !self::isTtySupported()) {\n            throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');\n        }\n\n        $this->tty = $tty;\n\n        return $this;\n    }\n\n    /**\n     * Checks if the TTY mode is enabled.\n     */\n    public function isTty(): bool\n    {\n        return $this->tty;\n    }\n\n    /**\n     * Sets PTY mode.\n     *","sourceCodeStart":1069,"sourceCodeEnd":1105,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Process.php#L1069-L1105","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n$process->setTty(true); // RuntimeException without /dev/tty\n\n// after\nif (\\Symfony\\Component\\Process\\Process::isTtySupported()) {\n    $process->setTty(true);\n}","handlingStrategy":"fallback","validationCode":"$ttyOk = \\Symfony\\Component\\Process\\Process::isTtySupported();\nif ($ttyOk) {\n    $process->setTty(true);\n}","typeGuard":null,"tryCatchPattern":"try {\n    $process->setTty(true);\n} catch (\\RuntimeException $e) {\n    // no /dev/tty: fall back to piped I/O\n}","preventionTips":["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."],"tags":["process","symfony","tty","dev-tty","environment"],"backgroundTag":"unsupported-platform","analyzedSha":"99b85026db14a68f02c6f3eeb01a1170ca25c491","analyzedAt":"2026-09-14T11:23:33.683Z","contentChangedAt":"2026-09-14T11:23:33.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}