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
- Read the exception message: it lists every registered formatter name in quotes
- Switch --output-format to one of the listed names (typically 'none' in the minimal install)
- composer require the package that provides the formatter you want and re-run so its service gets tagged
- 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
- Run vendor/bin/rector process --output-format once to see registered names before wiring CI
- Fail fast in wrappers: reject unknown --output-format values before the container boots
- Treat the quoted list inside the exception message as the API contract after each Rector upgrade
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
- [parallel] Main script was not found
- Short rule name "%s" is ambiguous. Specify the full rule nam
- Rule "%s" exists, but is not registered in your Rector confi
- Rule "%s" was not found.%sThe rule has no namespace. Make su
- Rule "%s" was not found.%sMake sure it is registered in your
AI-assisted analysis of rectorphp/rector@408fcb0ff1 (2026-08-21).
Data as JSON: /api/errors/4583aaf32dbceae9.
Report an issue: GitHub.