symfony/translation · error · InvalidArgumentException

The file dumper needs a path option.

Error message

The file dumper needs a path option.

What it means

Thrown by FileDumper::dump when the $options array does not contain the required 'path' key specifying where translation files should be written. All file-based dumpers (Yaml, Xliff, Po, etc.) inherit this requirement.

Solutions

  1. Pass `['path' => '/output/dir']` in the options array of dump()
  2. For the console command, ensure translation dump output path is configured/passed correctly
  3. Check any wrapper code that strips or filters options before calling dump()

Example fix

// before
$dumper->dump($catalogue, ['format' => 'yml']);
// after
$dumper->dump($catalogue, ['path' => '%kernel.project_dir%/translations', 'format' => 'yml']);
Defensive patterns

Strategy: validation

Validate before calling

if (!isset($options['path'])) { throw new \LogicException('dump() requires the "path" option.'); } $dumper->dump($catalogue, $options);

Try / catch

try { $dumper->dump($catalogue, $options); } catch (InvalidArgumentException $e) { if (str_contains($e->getMessage(), 'path option')) { // supply path and retry } }

Prevention

When it happens

Trigger: Calling `$dumper->dump($catalogue, $options)` without 'path' in $options, or using translation:dump/console commands with dumping configuration missing the output path.

Common situations: Programmatic dumping of catalogues (e.g. exporting translations in a script) where the options array was built conditionally and 'path' got omitted; misconfigured custom dumper services.

Understand the failure class

Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.

Related errors


AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15). Data as JSON: /api/errors/3a6ac33d29033eac. Report an issue: GitHub.

Appendix: source

Thrown at Dumper/FileDumper.php:44

abstract class FileDumper implements DumperInterface
{
    /**
     * A template for the relative paths to files.
     */
    protected string $relativePathTemplate = '%domain%.%locale%.%extension%';

    /**
     * Sets the template for the relative paths to files.
     */
    public function setRelativePathTemplate(string $relativePathTemplate): void
    {
        $this->relativePathTemplate = $relativePathTemplate;
    }

    public function dump(MessageCatalogue $messages, array $options = []): void
    {
        if (!\array_key_exists('path', $options)) {
            throw new InvalidArgumentException('The file dumper needs a path option.');
        }

        // save a file for each domain
        foreach ($messages->getDomains() as $domain) {
            $fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());
            if (!file_exists($fullpath)) {
                $directory = \dirname($fullpath);
                if (!file_exists($directory) && !@mkdir($directory, 0o777, true)) {
                    throw new RuntimeException(\sprintf('Unable to create directory "%s".', $directory));
                }
            }

            $intlDomain = $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX;
            $intlMessages = $messages->all($intlDomain);

            if ($intlMessages) {
                $intlPath = $options['path'].'/'.$this->getRelativePath($intlDomain, $messages->getLocale());
                file_put_contents($intlPath, $this->formatCatalogue($messages, $intlDomain, $options));

View on GitHub (pinned to ae9e8a51bc)