symfony/translation · error · InvalidArgumentException

The " " file does not exist.

Error message

The "%s" file does not exist.

What it means

Thrown by AbstractFileExtractor::isFile when a path passed to the extractor is not an existing file (is_file() fails). Translation extractors (PHP, Twig) call canBeExtracted(), which calls isFile(), for every candidate path.

Solutions

  1. Verify every configured source path exists (`ls` each dir) and fix typos
  2. Update extractor path configuration after moving/renaming source directories
  3. Remove or repair broken symlinks inside the scanned directories
  4. Run extraction from the project root so relative paths resolve correctly

Example fix

// before
bin/console translation:extract --dirs=src/Contollers app
// after
bin/console translation:extract --dirs=src/Controllers app
Defensive patterns

Strategy: validation

Validate before calling

foreach ($dirs as $dir) { if (!is_dir($dir)) { throw new \InvalidArgumentException("Extraction path does not exist: {$dir}"); } }

Type guard

function isExistingFilePath(string $file): bool { return is_file($file); }

Try / catch

try { $extractor->extract($directory, $catalogue); } catch (InvalidArgumentException $e) { if (str_contains($e->getMessage(), 'file does not exist')) { // fix configured path and retry } throw $e; }

Prevention

When it happens

Trigger: Running `php bin/console translation:extract` (or calling extractors directly) with source paths that don't exist — wrong --dirs values, deleted directories, path typos, or directories containing symlinks to missing files.

Common situations: Typo in the extraction directory configuration (framework.translation.extractor_paths or command --dirs); renamed/moved source folders; broken symlinks; running extraction on a machine without the full code checkout.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at Extractor/AbstractFileExtractor.php:52

        } else {
            $files = $this->extractFromDirectory($resource);
        }

        return $files;
    }

    private function toSplFileInfo(string $file): \SplFileInfo
    {
        return new \SplFileInfo($file);
    }

    /**
     * @throws InvalidArgumentException
     */
    protected function isFile(string $file): bool
    {
        if (!is_file($file)) {
            throw new InvalidArgumentException(\sprintf('The "%s" file does not exist.', $file));
        }

        return true;
    }

    abstract protected function canBeExtracted(string $file): bool;

    abstract protected function extractFromDirectory(string|array $resource): iterable;
}

View on GitHub (pinned to ae9e8a51bc)