Problem/Motivation

I have been trying to uninstall Lightning by following the steps shared on the official documentation page.

I upgraded my lightning distribution to the latest version as instructed.

Then I run pm:uninstall lightning

During the uninstalling process, there is an error that I believe needs attention:

The error says "Command pm:uninstall was not found." Strangely, after I run the command (pm:uninstall lightning), it seems that it is taking away so many drush commands including pm:enable pm:uninstall etc. My drush version is 10.5.0. Before I run pm:uninstall lightning, I check drush list and commands seem normal. But, after initiating the uninstall command, drush only lists part of the commands, I am also sharing the command list below right after the error message.

I am assuming the reduction in the commands happening due to the profile switch from "lightning" to "minimal". Apperantly, the uninstaller at the same time tries to use pm:uninstall command to uninstall profile_swticher module as part of the uninstallation process, which breaks the process.

Here's where the error happens.


Welcome to the Lightning uninstaller!
=====================================

Switching to minimal profile...
Modifying S:\Lab\xampp\htdocs\mysite\public_html\composer.json...

 * Ensuring direct Lightning dependencies are required
 * Ensuring required repositories are present
 * Adding required patches
 * Checking patcher configuration
 * Checking installer configuration
 * Checking scaffold configuration

 [success] Successfully uninstalled: lightning

In Process.php line 269:

  The command "S:\Lab\xampp\htdocs\mysite\vendor\drush\drush\drush pm:un
  install profile_switcher --yes --uri=default --root=S:\Lab\xampp\htdocs\mysite\public_html" failed.

  Exit Code: 1(General error)

  Working directory:

  Output:
  ================


  Error Output:
  ================



    Command pm:uninstall was not found. Pass --root or a @siteAlias in order to r
  un
     Drupal-specific commands.

Below is available drush commands:

Run `drush help [command]` to view command-specific help.  Run `drush topic` to read even more documentation.

 Available commands:
 _global:
   browse                               Display a link to a given path or open
                                        link in a browser.
   config:pull (cpull)                  Export and transfer config from one
                                        environment to another.
   deploy                               Run several commands after performing a
                                        code deployment.
   drupal:directory (dd)                Return the filesystem path for
                                        modules/themes and other key folders.
   entity:updates (entup)               Apply pending entity schema updates.
   generate (gen)                       Generate boilerplate code for
                                        modules/plugins/services etc.
   help                                 Display usage details for a command.
   list                                 List available commands.
   mk:docs                              Build a Markdown document for each
                                        Drush command thats available on a
                                        site.
   runserver (rs, serve)                Runs PHP's built-in http server for
                                        development.
   user:login (uli)                     Display a one time login link for user
                                        ID 1, or another user.
   version                              Show Drush version.
 cache:
   cache:clear (cc)                     Clear a specific cache, or all Drupal
                                        caches.
   cache:get (cg)                       Fetch a cached object and display it.
   cache:rebuild (cr, rebuild)          Rebuild a Drupal 8 site.
   cache:set (cs)                       Cache an object expressed in JSON or
                                        var_export() format.
   cache:tags (ct)                      Invalidate by cache tags.
 core:
   core:edit (conf, config)             Edit drush.yml, site alias, and Drupal
                                        settings.php files.
   core:init (init)                     Enrich the bash startup file with bash
                                        aliases and a smart command prompt.
   core:rsync (rsync)                   Rsync Drupal code or files to/from
                                        another server using ssh.
   core:status (status, st)             An overview of the environment - Drush
                                        and Drupal.
   core:topic (topic)                   Read detailed documentation on a given
                                        topic.
 php:
   php:eval (eval, ev)                  Evaluate arbitrary php code after
                                        bootstrapping Drupal (if available).
   php:script (scr)                     Run php a script after a full Drupal
                                        bootstrap.
 pm:
   pm:security (sec)                    Check Drupal Composer packages for
                                        pending security updates.
   pm:security-php (sec-php)            Check non-Drupal PHP packages for
                                        pending security updates.
 site:
   site:alias (sa)                      Show site alias details, or a list of
                                        available site aliases.
   site:alias-convert (sa-convert, sac) Convert legacy site alias files to the
                                        new yml format.
   site:install (si, sin)               Install Drupal along with
                                        modules/themes/configuration/profile.
   site:set (use)                       Set a site alias that will persist for
                                        the current session.
   site:ssh (ssh)                       Connect to a Drupal site's server via
                                        SSH, and optionally run a shell
                                        command.
 sql:
   sql:cli (sqlc)                       Open a SQL command-line interface using
                                        Drupal's credentials.
   sql:connect                          A string for connecting to the DB.
   sql:create                           Create a database.
   sql:drop                             Drop all tables in a given database.
   sql:dump                             Exports the Drupal DB as SQL using
                                        mysqldump or equivalent.
   sql:query (sqlq)                     Execute a query against a database.
   sql:sync                             Copy DB data from a source site to a
                                        target site. Transfers data via rsync.
 updatedb:
   updatedb (updb)                      Apply any database updates required (as
                                        with running update.php).
   updatedb:status (updbst)             List any pending database updates.

 ! [NOTE] Drupal root not found. Pass --root or a @siteAlias in order to see
 !        Drupal-specific commands.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

mustafaozcicek created an issue. See original summary.

avpaderno’s picture

Issue tags: -uninstall
phenaproxima’s picture

Assigned: Unassigned » phenaproxima
Status: Active » Needs work

I am assuming the reduction in the commands happening due to the profile switch from "lightning" to "minimal".

I don't see how this could be the case; Lightning has no influence on which Drush commands are available. Especially core commands like pm:enable.

What could be the case, though, is if Drush can no longer detect a completely functioning Drupal install at the place where you're running it. The commands that are available depend entirely on what "level" Drush can bootstrap Drupal into. So my suspicion here is that you have uncovered a legitimate bug, which is that Lightning is trying to invoke Drush in order to install profile_switcher, but it's inadvertently invoking the wrong Drush -- possibly a globally-installed Drush which is outside any particular Drupal installation.

I'll look into this and see if I can improve it, or at least reproduce it. What I would suggest as a workaround, in the meantime, is to make sure you've temporarily removed or disabled any globally installed version of Drush that might be in your system, so that Lightning's uninstaller is forced to use the Drush installation that is installed within your Drupal code base.

This is all speculation, of course, so I'm not sure that suggestion will work. But it's the only reason I can think of why you might be encountering this problem.

phenaproxima’s picture

Some quick research suggests a thing you could try: maybe run the uninstaller with the --root option that Drush supports pretty universally. Something like this:

drush pm:uninstall lightning --root=/path/to/your/drupal/installation

Would you be able to try that and report back? 🙏 Thanks again for the detailed error report and helping to make the uninstall process better for everyone.

maithili11’s picture

I am using Lightning 4.1.19 and after running pm:uninstall lightning, getting the same issue. Even after adding --root, it is not resolving the error.