Skip to content
Latchkey

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.

php
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 1

Common 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
php bin/console lint:container
php bin/console lint:yaml config/
php bin/console cache:clear -vvv

Fix the offending reference

  1. Read the compile error - it names the service and the missing/invalid dependency.
  2. Correct the service id, argument, or parameter it points at.
  3. Re-run cache:clear and confirm warmup completes.

Provide build-time env for prod warmup

A prod warmup may resolve env-dependent config; supply those env vars in CI.

php
export APP_ENV=prod
export DATABASE_URL="mysql://user:pass@127.0.0.1:3306/app"
php bin/console cache:clear --env=prod

How to prevent it

  • Run lint:container and lint:yaml in CI to catch compile errors early.
  • Keep service ids consistent when renaming/removing services.
  • Provide env vars required by prod container compilation in CI.

Frequently asked questions

What causes "compile error (cache:clear)"?
A wiring entry points at a service id that does not exist (renamed, removed, or typo'd), so compilation fails.
How do I fix compile error (cache:clear)?
Surface the exact failing service or syntax error.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card