magento2: bin/magento module:uninstall never completes

I’ve tested this on a fresh 2.0.2 installation.

I installed a sample module of mine using composer and then afterwards ran bin/magento module:uninstall Smartie_SampleModule

This is the output;


Enabling maintenance mode
You are about to remove a module(s) that might have database data. Remove the database data manually after uninstalling, if desired.
Removing Smartie_SampleModule from module registry in database
Removing Smartie_SampleModule from module list in deployment configuration
Removing code from Magento codebase:

This is where it gets stuck. The module is removed from the composer.json file but it never gets removed from the vendor dir.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 42 (7 by maintainers)

Commits related to this issue

Most upvoted comments

This should be reopened as it persists in 2.1.4. The workaround is Control-C on the command when it hangs at removing code, then run composer update, however this is not a solution. The module:uninstall should work properly otherwise why even have it?

So sick of issues like this in magento, I have a notepad filled with workarounds on things that should just work. Test your f’ing code better before releasing it. I’m starting to think CE is just a public beta for their money grab EE. About to recommend a different platform to all my clients. Fed up.

@andrew-smart : have you added any repositories to composer.json? I’ve seen this too, and my theory is that module:uninstall triggers composer update in another thread (or otherwise hides the output). Thus when composer prompts for credentials to our custom repo, it blocks, waiting on username and password from standard in, which magento never provides. An untested theory at this point; I don’t really know what it does under the covers.

The solution is to run : composer update in an other console

Well technically it isn’t a problem.

I documented my research here: https://blog.tschallacka.de/2021/05/binmagento-moduleuninstall-never.html and technically this isn’t a bug. It’s listed un the pre-requisites that you need to create an auth.json

https://devdocs.magento.com/guides/v2.4/install-gde/prereq/dev_install.html#authentication-file

So if you get this error, you basically skipped a step from he documentation. They could do adding an error message though. I made a pull request for that here https://github.com/magento/magento2/pull/32955

Hi all,

Thanks to @paulerickson and @Dayssam. Their debugging helped me fix this.

I found a solution or maybe a solution with limited scope. The following is my scenario.

  • Developed a custom module.
  • Created a git repo for it.
  • Installed it by following this link.

Now here is my solution to Uninstall command issue

In my auth.json file, I added another object for my module’s git repo and added the credentials just like we do for repo.magento.com. So, my auth.json file looks like the following now.

{
    "http-basic": {
        "repo.magento.com": {
            "username": "<public-key>",
            "password": "<private-key>"
        },
        "github.com/Jehangir-Wahid/<My-Repository-Name>": {
        	"username": "<my-github-username>",
        	"password": "<my-github-password>"
        }
    }
}

After setting it I ran php bin/magento module:uninstall Vendor_ModuleName command and it ran successfully with the following output.

You are about to remove code and/or database tables. Are you sure?[y/N]y Maintenance mode already enabled You are about to remove a module(s) that might have database data. Do you want to remove the data from database?[y/N]y You are removing data without a database backup. Removing data of Vendor_ModuleName Removing Vendor_ModuleName from module registry in database Removing Vendor_ModuleName from module list in deployment configuration Removing code from Magento codebase: Cache cleared successfully. Generated classes cleared successfully. Please run the ‘setup:di:compile’ command to generate classes. Info: Some modules might require static view files to be cleared. To do this, run ‘module:uninstall’ with the --clear-static-content option to clear them. Skipped disabling maintenance mode

Maybe it helps some of you people.

Composer stoped in load data from repo.magento.com

My auth.json was not correct. This decision helped me

config http-basic.repo.magento.com <public_key> <private_key> https://magento.stackexchange.com/questions/90983/how-to-use-the-new-repo-magento-com

Hi everyone

@paulerickson As you said , your theory is wright, it demand in background to enter your GitHub credentials to access private repos

This is what i get when i run the uninstall command line

Command "remove" failed: <warning>emizentech/shopbybrand is not required in your composer.json and has not been removed</warning>
Loading composer repositories with package information
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
A token will be created and stored in "/var/www/magento2/var/composer_home/auth.json", your password will never be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username: Password:
Bad credentials.
You can also manually create a personal token at https://github.com/settings/applications
Add it using "composer config github-oauth.github.com <token>"
Username: Password:
Bad credentials.
You can also manually create a personal token at https://github.com/settings/applications
Add it using "composer config github-oauth.github.com <token>"
Username: Password:
Bad credentials.
You can also manually create a personal token at https://github.com/settings/applications
Add it using "composer config github-oauth.github.com <token>"
Username: Password:
Bad credentials.
You can also manually create a personal token at https://github.com/settings/applications
Add it using "composer config github-oauth.github.com <token>"
Username: Password:
Bad credentials.
You can also manually create a personal token at https://github.com/settings/applications
Add it using "composer config github-oauth.github.com <token>"

  [RuntimeException]
  Invalid GitHub credentials 5 times in a row, aborting.

remove [--dev] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [packages1] ... [packagesN]

Please disable maintenance mode after you resolved above issues

Using M2.4.5-p1 and still hanging on “Removing code from Magento codebase:”

Hi all,

Thanks to @paulerickson and @Dayssam. Their debugging helped me fix this.

I found a solution or maybe a solution with limited scope. The following is my scenario.

  • Developed a custom module.
  • Created a git repo for it.
  • Installed it by following this link.

Now here is my solution to Uninstall command issue

In my auth.json file, I added another object for my module’s git repo and added the credentials just like we do for repo.magento.com. So, my auth.json file looks like the following now.

{
    "http-basic": {
        "repo.magento.com": {
            "username": "<public-key>",
            "password": "<private-key>"
        },
        "github.com/Jehangir-Wahid/<My-Repository-Name>": {
        	"username": "<my-github-username>",
        	"password": "<my-github-password>"
        }
    }
}

After setting it I ran php bin/magento module:uninstall Vendor_ModuleName command and it ran successfully with the following output.

You are about to remove code and/or database tables. Are you sure?[y/N]y Maintenance mode already enabled You are about to remove a module(s) that might have database data. Do you want to remove the data from database?[y/N]y You are removing data without a database backup. Removing data of Vendor_ModuleName Removing Vendor_ModuleName from module registry in database Removing Vendor_ModuleName from module list in deployment configuration Removing code from Magento codebase: Cache cleared successfully. Generated classes cleared successfully. Please run the ‘setup:di:compile’ command to generate classes. Info: Some modules might require static view files to be cleared. To do this, run ‘module:uninstall’ with the --clear-static-content option to clear them. Skipped disabling maintenance mode

Maybe it helps some of you people.

I added auth.json file, but still stuck in Removing code from Magento codebase. my Magento is version 2.4.3.

@Dayssam , yes, that solution works if you canceled the module:uninstall command previously.