I made some changes to own services and now I get an error about invalid arguments. When I clear all caches everything works fine. I don't want to clear all caches in my production environment. Which cache bin (and how) do I need to clear? I use drupal console. I tried 'drupal cache:rebuild container' but I get a message 'Cache container is invalid'.
Drupal Console uses
Cache::getBins() for its list of valid cache bins - that method returns all services in the main container tagged with
container cache service is part of the bootstrap container, which is managed internally by
I haven't dug deep enough to know for sure, but keeping the management of that bin internal seems to be deliberate, so there's probably no simple (maybe even no desirable) way to hack around it.
Fortunately, a custom plugin for Console is easy to create with
drupal generate:command (there's a tutorial here). Just be sure to inject the
kernel service, and call
$this->kernel->invalidateContainer(); in the command 's action callback.
There are no real guarantees about what needs to be invalidated when you change dependencies. The service definition for the compiled container doesn't match up with the PHP class constructors it is referencing, so you are getting errors. So, you need to do a full container rebuild, which will also trigger a cache clear.
The proper way to do this when pushing a change to a new environment is to add a an empty
hook_update_N() to your module defining the service. It can also be done with an empty
hook_post_update_NAME, which is what core tends to do to avoid patch conflicts (among other reasons).
Then, after deployment you can do a
drush updb, which will run all pending updates.