Permissions are clobbered because Drupal uses NestedArray::mergeDeepArray()
to merge overrides with existing config.
For example, if we have this permissions
$ drush cget user.role.anonymous permissions
'user.role.anonymous:permissions':
- 'access content'
- 'access comments'
and then add
$config['user.role.anonymous']['permissions'][] = 'use browsersync';
to settings.php
, the result will be
$ drush cget user.role.anonymous permissions
'user.role.anonymous:permissions':
- 'use browsersync'
- 'access comments'
An easy way to workaround this would be
$config['user.role.anonymous']['permissions'][9999] = 'use browsersync';
which will result in
$ drush cget user.role.anonymous permissions
'user.role.anonymous:permissions':
0:'access content'
1:'access comments'
9999: 'use browsersync'
But if you need to remove a permission via settings.php
, then I honestly don't know how to do it, even with module config overrides system (which has an ability to load original config before providing the override). Maybe overriding the unwanted permission with NULL
may work, but I haven't tried.