Skip to content

[ax] Do not prompt or auto-create config on non-TTY - #8454

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-no-config-prompt-non-tty
Sep 4, 2026
Merged

[ax] Do not prompt or auto-create config on non-TTY#8454
TomasVotruba merged 2 commits into
mainfrom
tv-no-config-prompt-non-tty

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Why

Running rector process with no rector.php in a non-interactive context (piped, CI, an agent) currently:

  • prints the interactive prompt No "rector.php" config found. Should we generate it for you? [yes]: into the output, then
  • auto-answers the default yes and silently writes a rector.php into the project - a file the caller never asked for.

Symfony still treats a closed STDIN as interactive here, so the prompt is emitted and defaulted rather than skipped. For an agent this is a surprising side effect plus confusing prompt noise (and a hang risk when stdin is a pty with no human to answer).

What

Guard the prompt on a non-TTY STDIN: emit a clear, actionable message and return - no prompt, no unrequested file.

if (! (defined('STDIN') && stream_isatty(STDIN))) {
    $this->symfonyStyle->warning(sprintf(
        'No "%s" config found. Create one, or pass "--config <path>".',
        RectorConfigsResolver::DEFAULT_CONFIG_FILE
    ));
    return;
}

Trade-off: this drops the convenience of auto-scaffolding a config in non-interactive contexts. That silent write is the bug being fixed.

Verification

rector process src --dry-run < /dev/null in a dir with no config:

  • before: prompt printed, rector.php created
  • after: [WARNING] No "rector.php" config found. Create one, or pass "--config <path>.", no file created

Env-dependent (reads the real STDIN stream), so verified via the CLI rather than a unit test.

@TomasVotruba
TomasVotruba merged commit 29758d2 into main Sep 4, 2026
43 checks passed
@TomasVotruba
TomasVotruba deleted the tv-no-config-prompt-non-tty branch September 4, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants