How to fix: RuntimeException: Adding non-existent permissions to a role is not allowed

I stumbled upon this error after removing a block type 'logo_listing':

RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "create logo_listing block content", "delete any logo_listing block content", "update any logo_listing block content". in Drupal\user\Entity\Role->calculateDependencies() (line 207 of core/modules/user/src/Entity/Role.php).

Solution

For some reason the system was thinking the user still had these permission, while they were not found in the database.

  • export your current config (drush cex)
  • In your config folder, search for the permission
  • In my case it was stated in user.role.content_editor.yml
  • remove every line that holds permission of this block type
  • import your config

Now the error disappeared!

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!