Drupal error caused by CTools and Pathauto incopatibility: The context is not a valid context

If you're using drupal/ctools 3.10+ or 4.0.1+ in combination with drupal/pathauto and some other modules you might have experienced a not too helpful critical PHP error:

[error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. in Drupal\Core\Executable\ExecutablePluginBase->getContextDefinition() (line 184 of docroot/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php)

This is because of recent changes in Chaos Tools, see #3300682

How to fix?

Option 1:

Add to your root composer file following:

"conflict": {
  "drupal/ctools": "^3.10 || ^4.0.1"
},

Option 2:

Starting with Pathauto v8.x-1.11 Chaos Tools dependency has been removed completely. This is possible due to a long standing core's issue Add entity bundles condition plugin for entities with bundles finally got resolved.

To do things correctly...

Get latest Pathauto

composer require 'drupal/pathauto:^1.11'

make a deployment and run database updates.

If there are no other modules depending on Chaos Tools, uninstall and add following to your composer file to get rid of Chaos Tools completely.

"replace": {
  "drupal/ctools": "*"
},

 

********************************** ************************* ************************ **************** ****************** *********** ************** ************* ************ *************