Symfony: Compile Error During cache:clear in CI
Symfony recompiles the service container during cache:clear/cache:warmup. A compile error - invalid config, an unknown service id referenced, a misconfigured compiler pass, or a bad parameter - aborts the build before the cache is warmed, failing the CI step.
What this error means
bin/console cache:clear in CI fails with a container compile error: an unknown service, an invalid argument, a YAML/XML syntax error, or a parameter that cannot resolve. The build dies during warmup, not at request time.
In YamlFileLoader.php line ...:
The service "App\Handler" has a dependency on a non-existent service
"app.legacy_logger".
# bin/console cache:clear --env=prod returns error code 1Common causes
A service references a non-existent dependency
A wiring entry points at a service id that does not exist (renamed, removed, or typo'd), so compilation fails.
Invalid config or a bad compiler pass
A YAML/XML syntax error, an invalid argument type, or a misbehaving compiler pass makes the container fail to compile.
How to fix it
Lint the container and config
Surface the exact failing service or syntax error.
php bin/console lint:container
php bin/console lint:yaml config/
php bin/console cache:clear -vvvFix the offending reference
- Read the compile error - it names the service and the missing/invalid dependency.
- Correct the service id, argument, or parameter it points at.
- Re-run
cache:clearand confirm warmup completes.
Provide build-time env for prod warmup
A prod warmup may resolve env-dependent config; supply those env vars in CI.
export APP_ENV=prod
export DATABASE_URL="mysql://user:pass@127.0.0.1:3306/app"
php bin/console cache:clear --env=prodHow to prevent it
- Run
lint:containerandlint:yamlin CI to catch compile errors early. - Keep service ids consistent when renaming/removing services.
- Provide env vars required by prod container compilation in CI.