I am trying to uninstall Lightning. When I run
drush pm:uninstall lightning, it throws this error.
In PmCommands.php line 196:
lightning: The Lightning module is required
How can I resolve this?
Lightning is a distribution, not a module. Distributions and installation profiles cannot be uninstalled, once used to create a site. That's why the Lightning distribution hooks into the
drush pm:uninstall command to make it possible.
If you aren't getting any Welcome to the $profile name uninstaller! message, it means the installed Lightning distribution needs to be first updated, as Uninstalling Lightning suggests.
- If you're using Lightning 3, use the latest 3.4.x version.
- If you're using Lightning 4, use the latest 4.1.x version.
- If you're using Lightning 5, use the latest 5.2.x version.
- If you're using Headless Lightning, use the latest 1.9.x version.
That page gives also other suggestions, for example the following one, for the commands that need to be executed before
drush pm:uninstall lightning.
If you're using BLT and
drush status --fields=install-profilereports that you're directly using the lightning or headless_lightning profiles, edit blt/blt.yml and change the profile key to minimal. Do NOT do this if you're using a sub-profile of Lightning or Headless Lightning.
As for running
drush pm:uninstall lightning, these are the suggestions given for that.
drush pm:uninstall lightningto use the automated uninstall tool, which will ensure that Lightning can be uninstalled safely by making the necessary code and configuration changes. If you're using a sub-profile of Lightning, you can allow the uninstaller to decouple all sub-profiles automatically by answering the prompt, or see "Decoupling a sub-profile from Lightning" below to do it manually (all sub-profiles, in use or not, must be decoupled from Lightning before you continue). IMPORTANT: If you're using Headless Lightning or a sub-profile of it, run
drush pm:uninstall headless_lightningBEFORE running
drush pm:uninstall lightning.
drush pm:uninstall lightning, the next step is the following one.
Export config, then commit all changes and deploy them to your hosting. At a minimum, you should expect to see changes in your project-level composer.json and core.extension config.
When Lightning hooks into the
drush pm:uninstall command, it executes the following commands, which essentially switch the profile from Lightning to another one.
drush pm:enable profile_switcher
drush switch:profile $profile
I didn't find any reference to the Profile Switcher module, in the Lightning distribution, despite it is necessary to switch the installation profile, which makes possible to uninstall the distribution. (Otherwise,
drush pm:uninstall lightning would return the The Lightning module is required error.)
If updating the distribution doesn't install it, I would manually install it.
Also, the Lightning hook adds a required option to
drush pm:uninstall, profile, which the installation profile to use instead of the distribution. If after updating the Lightning distribution and following the suggestions given in Uninstalling Lightning, you get an error about the profile option not found or required, try running
drush pm:uninstall lightning --profile='default' instead of
drush pm:uninstall lightning, which would pass the profile option to the command and the hook added by the distribution.