doctrine/orm · error · InvalidArgumentException

Proxies destination directory '<info>%s</info>' does not exi

Error message

Proxies destination directory '<info>%s</info>' does not exist.

What it means

After resolving dest-path (argument or configured proxy dir), orm:generate-proxies creates the directory if missing and resolves it with realpath(). If the path still cannot be resolved — mkdir() failed silently on an unwritable parent, a regular file occupies the path, or open_basedir blocks access — the file_exists() check fails and the command throws InvalidArgumentException('Proxies destination directory ... does not exist'). Note the message prints the configured proxy dir, not necessarily the path you passed.

Source

Thrown at src/Tools/Console/Command/GenerateProxiesCommand.php:77

        // Process destination directory
        $destPath = $input->getArgument('dest-path');
        if ($destPath === null) {
            $destPath = $em->getConfiguration()->getProxyDir();

            if ($destPath === null) {
                throw new InvalidArgumentException('Proxy directory cannot be null');
            }
        }

        if (! is_dir($destPath)) {
            mkdir($destPath, 0775, true);
        }

        $destPath = realpath($destPath);

        if (! file_exists($destPath)) {
            throw new InvalidArgumentException(
                sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $em->getConfiguration()->getProxyDir()),
            );
        }

        if (! is_writable($destPath)) {
            throw new InvalidArgumentException(
                sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath),
            );
        }

        if (empty($metadatas)) {
            $ui->success('No Metadata Classes to process.');

            return 0;
        }

        foreach ($metadatas as $metadata) {
            $ui->text(sprintf('Processing entity "<info>%s</info>"', $metadata->name));

View on GitHub (pinned to d9b9ff7301)

Solutions

  1. Create the tree first: mkdir -p var/cache/prod/doctrine/orm/Proxies, then re-run the command.
  2. Check the configured proxy_dir for typos and ensure every parent exists and is writable by the CLI user.
  3. If open_basedir is enabled, add the proxy directory to the allowed paths.

Example fix

# before
$ php bin/console orm:generate-proxies
# InvalidArgumentException: Proxies destination directory '...' does not exist.

# after
$ mkdir -p var/cache/prod/doctrine/orm/Proxies
$ php bin/console orm:generate-proxies var/cache/prod/doctrine/orm/Proxies
Defensive patterns

Strategy: validation

Validate before calling

$dir = $em->getConfiguration()->getProxyDir();
if ($dir !== null && ! is_dir($dir)) {
    if (! @mkdir($dir, 0775, true) && ! is_dir($dir)) {
        throw new RuntimeException("Cannot create proxy directory $dir");
    }
}
// run orm:generate-proxies

Prevention

When it happens

Trigger: dest-path under a parent directory that does not exist or is not writable (mkdir() returns false, which the command does not check); a regular file sitting at the proxy-dir path; open_basedir restrictions in hardened CLI setups; typos in the configured proxy_dir.

Common situations: Fresh deploys where var/ subdirectories were never created; Docker volumes mounted after the image expected the path; relative proxy_dir resolved against a different CLI working directory.

Related errors


AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21). Data as JSON: /api/errors/acb2cf7c1998a710. Report an issue: GitHub.