rectorphp/rector · error · InvalidConfigurationException

Output formatter "%s" was not found. Pick one of "%s".

Error message

Output formatter "%s" was not found. Pick one of "%s".

What it means

OutputFormatterCollector::getByName() looks up the formatter tagged service matching the requested name (typically from --output-format on the CLI). When no registered formatter carries that name, ensureOutputFormatExists() throws InvalidConfigurationException and embeds the sorted list of names that ARE registered, so the message itself is the discovery mechanism.

Source

Thrown at src/Console/Output/OutputFormatterCollector.php:34

     */
    public function __construct(iterable $outputFormatters)
    {
        foreach ($outputFormatters as $outputFormatter) {
            $this->outputFormatters[$outputFormatter->getName()] = $outputFormatter;
        }
    }
    public function getByName(string $name): OutputFormatterInterface
    {
        $this->ensureOutputFormatExists($name);
        return $this->outputFormatters[$name];
    }
    private function ensureOutputFormatExists(string $name): void
    {
        if (isset($this->outputFormatters[$name])) {
            return;
        }
        $outputFormatterNames = array_keys($this->outputFormatters);
        throw new InvalidConfigurationException(sprintf('Output formatter "%s" was not found. Pick one of "%s".', $name, implode('", "', $outputFormatterNames)));
    }
}

View on GitHub (pinned to 408fcb0ff1)

Solutions

  1. Read the exception message: it lists every registered formatter name in quotes
  2. Switch --output-format to one of the listed names (typically 'none' in the minimal install)
  3. composer require the package that provides the formatter you want and re-run so its service gets tagged
  4. Check for typos/whitespace in the CLI option value

Example fix

// before
$ vendor/bin/rector process src --output-format=xml
// Output formatter "xml" was not found. Pick one of "none".

// after
$ vendor/bin/rector process src --output-format=none
Defensive patterns

Strategy: try-catch

Try / catch

try {
    $formatter = $outputFormatterCollector->getByName($requestedName);
} catch (InvalidConfigurationException $e) {
    // message lists valid names: pick a safe default instead of aborting
    $formatter = $outputFormatterCollector->getByName('none');
}

Prevention

When it happens

Trigger: Running vendor/bin/rector process src --output-format=json (typo, unregistered, or not-installed formatter); calling OutputFormatterCollector::getByName('xml') programmatically when only other formatters are tagged in the container.

Common situations: Expecting a JSON/JUnit formatter that lives in a separate package that is not installed; typos like '--output-format=none ' with trailing whitespace; CI pipelines hard-coding a formatter name that a Rector upgrade renamed.

Related errors


AI-assisted analysis of rectorphp/rector@408fcb0ff1 (2026-08-21). Data as JSON: /api/errors/4583aaf32dbceae9. Report an issue: GitHub.