How do I create a role programmatically?
The problem is in the data array change name by label:

$role = \Drupal\user\Entity\Role::create(array('id' =&gt; 'client', 'label' =&gt; 'Client'));
$role-&gt;save(); 


Or you can use:

//your data array
$data = array('id' =&gt; 'client', 'label' =&gt; 'Client');
//creating your role
$role = \Drupal\user\Entity\Role::create($data);
//saving your role
$role-&gt;save();