Skip to content

Respect TTY availability when running the dev server - #144

Open
Ikromjon1998 wants to merge 1 commit into
NativePHP:mainfrom
Ikromjon1998:fix/respect-tty-support-in-dev-server
Open

Respect TTY availability when running the dev server#144
Ikromjon1998 wants to merge 1 commit into
NativePHP:mainfrom
Ikromjon1998:fix/respect-tty-support-in-dev-server

Conversation

@Ikromjon1998

Copy link
Copy Markdown

Running php artisan native:run (or native:serve) outside an interactive terminal fails before the process starts:

Symfony\Component\Process\Exception\RuntimeException

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

  at vendor/symfony/process/Process.php:1087

ExecuteCommand::executeCommand() enables TTY mode whenever the caller has not explicitly asked for non-interactive mode, without checking whether a TTY is actually available:

->tty(! $withoutInteraction && PHP_OS_FAMILY != 'Windows')

So the dev server cannot be started from CI, a scripted deploy, an editor task runner, or any background shell. --no-interaction does not help: it is threaded through to the dependency install, but the dev invocation still requests a TTY.

BuildCommand already guards against this (BuildCommand.php:183):

->tty(SymfonyProcess::isTtySupported() && ! $this->option('no-interaction'))

This applies the same isTtySupported() check in executeCommand(), so both paths behave consistently. Where a TTY exists the behaviour is unchanged; where none exists the process now runs with piped output instead of throwing.

Verifying

With this change, php artisan native:run starts normally in a non-interactive shell where it previously aborted at the TTY check. Without it, the same invocation needs a pseudo-terminal wrapper (script -q /dev/null php artisan native:run) as a workaround.

Pint and PHPStan pass on the changed file.

executeCommand() enables TTY mode whenever the caller has not asked for
non-interactive mode, without checking whether a TTY is actually
available. In any environment without one — CI, a scripted deploy, an
editor task runner, a background shell — Symfony throws before the
process starts:

    TTY mode requires /dev/tty to be read/writable.
    at vendor/symfony/process/Process.php:1087

This makes `native:run` and `native:serve` unusable outside an
interactive terminal. `--no-interaction` does not help, because it is
only threaded through to the dependency install; the dev server call
still requests a TTY.

BuildCommand already guards this with Process::isTtySupported(), so this
applies the same check here and keeps the two paths consistent.
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.

1 participant