Problem/Motivation

Part of #3582246: [meta] CLI in Core community initiative. Referenced from theCLI in Core Initiative spreadsheet.

Steps to reproduce

Working on a Drupal Core CLI Command issue > Test Commands

Install an optional module with dependencies such as rest, workspaces_ui.

Test uninstalling a module is not installed, one that is a dependency of another installed module, and one that is not a dependency and is installed.

Proposed resolution

To be determined.

Remaining tasks

User interface changes

To be determined.

Introduced terminology

To be determined.

API changes

To be determined.

Data model changes

To be determined.

Release notes snippet

To be determined.

Issue fork drupal-3594335

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    3 hidden branches
  • uninstall Comparechanges, plain diff MR !17083
  • main Comparecompare
  • 3594335-add-a-module Comparecompare

Comments

mradcliffe created an issue. See original summary.

mradcliffe’s picture

Added link to #2894476: [PP-1] Provide commands which are helpful for core development that was the original feature request, but no work was done on uninstalling extensions in that issue.

nicxvan’s picture

Component: system.module » extension system
mradcliffe’s picture

Updated parent to the "stable" meta. Added testing instructions.

ressa’s picture

I would like to suggest that old aliases are not included, so that only ex:uninstall and its alias exun are available.

$ dr ex:uninstall -h
Description:
  Uninstalls one or more modules or themes.

Usage:
  ex:uninstall [options] [--] <extensions>
  exun

General help

$ dr
[...]
 ex
  ex:uninstall      [exun] Uninstalls one or more modules or themes.
moshe weitzman’s picture

Assigned: Unassigned » moshe weitzman

Assigning to me.

moshe weitzman’s picture

Status: Active » Needs review

Ready for review. Closely matches the code flow and UX of the new ex;install command.

mradcliffe’s picture

nicxvan changed the visibility of the branch 3594335-add-a-module to hidden.

nicxvan changed the visibility of the branch main to hidden.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

nicxvan’s picture

Ok I manually ran through the following test scenarios similar to the install command tests:

With CLI

  • I uninstalled a module by itself - Worked
  • I called two modules, one already uninstalled - Worked
  • I uninstalled a theme - Worked
  • I uninstalled a module with dependencies - Worked
  • I uninstalled an already uninstalled module - Worked
  • I uninstalled a theme with subtheme dependencies - Worked
  • I uninstalled a theme with module dependencies - Worked
  • I uninstalled a module and theme at the same time - (gave appropriate error)
  • I uninstalled a profile - Worked
  • I uninstalled an experimental theme - Worked
  • I uninstalled an experimental module - Worked
  • I uninstalled the default theme - (gave appropriate error)

IN UI

  • I uninstalled a module by itself - Worked
  • I called two modules, one already uninstalled - N/A
  • I uninstalled a theme - Worked
  • I uninstalled a theme with subtheme dependencies - N/A
  • I uninstalled a theme with module dependencies - Worked
  • I uninstalled an already uninstalled module - N/A
  • I uninstalled a module and theme at the same time - N/A
  • I uninstalled a profile - Worked
  • I uninstalled an experimental theme - Worked
  • I uninstalled an experimental module - Worked
  • I uninstalled the default theme - N/A

Happy to report that everything worked!

@godotislate mentioned in slack that main is now for criticals and 12.x only for a bit so I think this won't get in until 12.x beta is out which means we'll need a separate CR for this.

The test still needs to be moved to the Extension test namespace.

I had wondered if some of the command code can be refactored into helpers since it looks like a few chunks are almost identical. I think that might be premature since this is only the second use, and there are enough minor differences that it could be painful.

moshe weitzman’s picture

Status: Needs work » Needs review

The Needs Review bot is again defacing issues by moving the status to Needs Work and attaching a file "Patch fails to apply". We dont use patches anymore. Also, the MR is mergeable as seen on this issue and on the MR itself.

If someone could review this that would be appreciated.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

nicxvan’s picture

There is something weird going on for sure.

I pulled the diff down https://git.drupalcode.org/project/drupal/-/merge_requests/17083.diff and created a patch from it.

When I apply that to main I get an error:

error: core/modules/system/src/Command/ExtensionInstallCommand.php: No such file or directory
error: core/modules/system/tests/src/Kernel/Command/ExtensionInstallCommandTest.php: No such file or directory

If you look at the diff it still references those files even though the MR doesn't appear to, I think gitlab or fastly is caching something incorrectly.

For the record the bot says patches, but it's using the MR as well.

moshe weitzman’s picture

Git has smarts to know about file moves/renames and all sorts of things. Thats why MRs stay green longer than patches too. Now that we have change proposals in git, I dont see value in knowing whether a derived patch would apply cleanly. I wrote about this 10 years ago.

nod_’s picture

The process of a core commit involves applying the .diff to the codebase, that's why the bot test for that. Bot is here to make sure a RTBC issue is committable at all times, without relaunching a unreasonable amount of CI test runs, which is why it doesn't trigger a rebase automatically either.

nicxvan’s picture

Ok I rebased, we still need the CR I think.

mradcliffe’s picture

The Drupal Contribution Mentoring team is triaging issues for DrupalCon Rotterdam 2026, and we are reserving this issue for Mentored Contribution during the event.

After October 3, this issue returns to being open to all. Thanks!

I performed Novice Triage on this issue. I am adding the Novice tag for creating a change record for the new methods that are added on the merge request. This is a non-code contribution opportunity.

Please remove the Needs change record and/or Needs issue summary update tags once that task is complete.

kristiantosney’s picture

I am at DrupalCon Rotterdam 2026, today I will be working on this issues. My mentor is Ekes.

kristiantosney’s picture

Issue tags: -Needs change record

I have written a change record for review on this issue.

mradcliffe’s picture

@kristiantosney Thank you for creating the change record. I forgot to mention this in my comment, but this should document the new methods on the respect Uninstall interfaces. If you have time, would you be able to update the change record so that it is similar to https://www.drupal.org/node/3623057?

vasyl vasylkiv’s picture

Status: Needs work » Needs review

@mradcliffe, I added the description for CR according to https://www.drupal.org/node/3623057/ example

mradcliffe’s picture

Status: Needs review » Needs work

@vasyl vasylkiv, thank you for updating the change record. However the change record needs to document the two new methods on the interface similar to the other change record you linked. I would probably title similarly as well.

moshe weitzman’s picture

This issue is now held up on a change record on an interface which virtually noone has ever extended. And will that person actually find and benefit from this CR? If someone finds an issue with an MR, it would be ideal if they made the accompanying change in order to keep it moving forward. Thank you.

larowlan’s picture

Status: Needs work » Needs review

Repurposed the change record - onwards

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

This issue is now held up on a change record on an interface which virtually noone has ever extended.

Yes, we still need a change record though.

I updated the change record a bit, I think it's good to go.

If someone finds an issue with an MR, it would be ideal if they made the accompanying change in order to keep it moving forward. Thank you.

People can do that, but then it generally removes their ability to RTBC cleanly, it's usually better for one person to take point.

In any case I think this is ready!

moshe weitzman’s picture

> People can do that, but then it generally removes their ability to RTBC cleanly, it's usually better for one person to take point.

Thanks for moving this along.

IMO its a bug in the policy if we are preventing or disincentivizing a person from making a fix when they see a problem in an MR. We should prioritize forward progress, not high fidelity to a peer review flow. It is still within the spirit of our workflow to make improvements AND provide the RTBC. Remember, rules are meant to be broken (wisely).

larowlan’s picture

Manually tested

71faf1f882de:/data$ dr en -y comment
The following module will be installed:
 * Comment (comment)


 [OK] Successfully installed 1 module.


 * Comment (comment) — Help, Permissions, Configure

71faf1f882de:/data$ dr pmu comment
The following module will be uninstalled:
 * Comment (comment)


 [OK] Successfully uninstalled 1 module.


71faf1f882de:/data$ dr en -y history
The following module will be installed:
 * History (history)


 [OK] Successfully installed 1 module.


 * History (history) — Help

71faf1f882de:/data$ dr pmu history
The following module will be uninstalled:
 * History (history)


 [OK] Successfully uninstalled 1 module.

Works like it says on the tin

I wonder if we have plans to support variadic arguments rather than a csv list?

71faf1f882de:/data$ dr pmu node stark

  Too many arguments to "pmu" command, expected arguments "extensions".
larowlan’s picture

Tested a few other scenarios

71faf1f882de:/data$ dr pmu node
The following module will be uninstalled:
 * Node (node)

The following additional module will be uninstalled as a dependency:
 * Taxonomy (taxonomy)

 Uninstall 1 additional module as a dependency? (yes/no) [yes]:
 >

  • larowlan committed 3b94128e on main
    feat: #3594335 Add a module and theme uninstall command
    
    By: mradcliffe...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 3b94128e929 to main. Thanks!

Published the change record

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

nicxvan’s picture

Assigned: moshe weitzman » Unassigned
Issue tags: -Needs issue summary update

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.