Change record status: 
Project: 
Introduced in branch: 
11.5.x
Introduced in version: 
11.5.0
Description: 

Since Drupal 10.3, it's been possible to uninstall an install profile, just like any module:

Drupal::service('module_installer')->uninstall(['my_profile']);

This works as long as the profile does not physically contain any installed modules or themes (e.g. profiles/foo/modules/my_special_module). If it does, an exception is thrown.

Install profiles can now opt into being automatically uninstalled by the install system, by adding this to the info file:

keep_profile: false

Profiles that do not set this flag will remain installed, same as they do now. And, as now, an exception is thrown if the profile being uninstalled contains any active modules or themes.

This is ideal for profiles which do not contain any special modules or themes, but which only want to customize the install experience (adding additional steps, using a different installer theme, etc.).

Impacts: 
Site builders, administrators, editors
Site templates, recipes and distribution developers