doctrine/orm · error · InvalidArgumentException
Proxies destination directory '<info>%s</info>' does not hav
Error message
Proxies destination directory '<info>%s</info>' does not have write permissions.
What it means
The last filesystem gate in orm:generate-proxies: the resolved destination directory must be writable because the command writes the generated proxy class files into it. When is_writable($destPath) is false — wrong owner, read-only filesystem — it throws InvalidArgumentException('...does not have write permissions').
Source
Thrown at src/Tools/Console/Command/GenerateProxiesCommand.php:83
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));
}
// Generating Proxies
$em->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
// Outputting information messageView on GitHub (pinned to d9b9ff7301)
Solutions
- Fix ownership and mode: chown -R <user>: var/cache/... and chmod -R u+w (or run the command as the directory owner).
- Point proxy_dir at a path guaranteed writable by the CLI user (e.g. under var/cache or artifacts baked into the image).
- On read-only-filesystem deployments, generate proxies at build time instead of deploy time.
Example fix
# before $ php bin/console orm:generate-proxies # InvalidArgumentException: ... does not have write permissions. # after $ sudo chown -R $(whoami): var/cache/prod/doctrine/orm/Proxies $ chmod -R u+w var/cache/prod/doctrine/orm/Proxies $ php bin/console orm:generate-proxies
Defensive patterns
Strategy: validation
Validate before calling
$dir = $em->getConfiguration()->getProxyDir();
if ($dir !== null && ! is_writable($dir)) {
throw new RuntimeException('Proxy directory ' . $dir . ' is not writable by user ' . get_current_user());
}
// run orm:generate-proxies Prevention
- Run the command as the same user that owns the cache/proxy directories, or fix ownership first.
- Generate proxies at build time on read-only filesystem deployments.
- Include an is_writable() preflight check in deploy scripts.
When it happens
Trigger: The proxy directory is owned by a different user than the one running the command (root-created var/ during image build, deploy user runs CLI); read-only or immutable filesystems; directories created by php-fpm with restrictive modes; group write missing on shared setups.
Common situations: Deploy pipelines switching users between build and release steps; Docker volumes with wrong ownership; shared hosting where the web server user owns cache directories.
Related errors
- Proxies destination directory '<info>%s</info>' does not exi
- Proxy directory cannot be null
- The directory "%s" does not exist and could not be created.
- The directory "%s" is not writable.
- No second-level cache is configured on the given EntityManag
AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21).
Data as JSON: /api/errors/c3ef4b92999cd9a3.
Report an issue: GitHub.