Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/magento module:uninstall never completes #3544

Closed
andrew-smart opened this issue Feb 25, 2016 · 42 comments · May be fixed by #32955
Closed

bin/magento module:uninstall never completes #3544

andrew-smart opened this issue Feb 25, 2016 · 42 comments · May be fixed by #32955
Labels
Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update

Comments

@andrew-smart
Copy link
Contributor

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.

@mazhalai
Copy link
Contributor

How long did you wait @andrew-smart?

@andrew-smart
Copy link
Contributor Author

I ran another test and so far i have waited 30 minutes without any further output. Not sure how long i should wait but that seems quite excessive :)

@mazhalai
Copy link
Contributor

@andrew-smart sorry for the delay, can you please give us more details about your env, like OS, and PHP version, so that we can try to reproduce this.

@mazhalai mazhalai added the PS label Mar 28, 2016
@paulerickson
Copy link

@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.

@mazhalai
Copy link
Contributor

mazhalai commented May 9, 2016

@andrew-smart closing this as non-responsive.

@mazhalai mazhalai closed this as completed May 9, 2016
@andrew-smart
Copy link
Contributor Author

@mazhalai My Apologies. I have not been getting updates from this ticket.
I run natively on mac osx with brew installed php 5.6.20 and mysql 5.6.27 with native apache.

@paulerickson Yes this is a custom repo. I built it to test the new uninstall scripts within modules. Your theory is quite interesting but not sure how I can test it.

@mhabou
Copy link

mhabou commented May 18, 2016

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

@mhabou
Copy link

mhabou commented May 18, 2016

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

@gabriellucius
Copy link

I have the same problem here, I call the bin/magento module:uninstall module_name and the command prompt stops in "Removing code from Magento codebase" too.

Any sollutions or fixes discovered?

Obs: All the data to be uninstalled were uninstaled

@hostep
Copy link
Contributor

hostep commented Aug 3, 2016

Linking this thread to an issue I discovered last week, it might be the same problem: #5797

@twistedatrocity
Copy link

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.

@akoslovasz
Copy link

I've done some debugging, and it seems the problem is with the Magento repository. When calling bin/magento module uninstall Vendor_Module, it calls composer remove in the background, and the method addRepository in Composer\DependencyResolver\Pool somehow gets into an infinite loop. Temporarily removing the Magento repository from composer.json fixes the problem. Anyway, a proper final solution would be useful.

@vasilii-b
Copy link

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

@nickbartlett
Copy link

nickbartlett commented Jun 1, 2017

@mazhalai can this issue be re-opened please? We have the same issue as @andrew-smart initially described. Uninstalling a module will remove the entry from composer.json, and run the database uninstall scripts, but when it attempts to remove the code it hangs with message "removing code from Magento codebase:" . One thing to note is our module has its own composer.json file where it requires and installed another codebase.

As I see in vendor/magento/framework/Composer/Remove.php, Magento tries to run 'remove' composer command.
runComposerCommand() method can be found here: vendor/magento/composer/src/MagentoComposerApplication.php
it gets stuck on line $exitCode = $this->consoleApplication->run($input, $this->consoleOutput);

FYI manually executing the command "composer remove my/module" works successfully.

@andidhouse
Copy link

I this fixed in 2.1.7 or 2.1.8 @magento-team ?

@joaoasrosa
Copy link

@andidhouse I just try it on 2.1.8 and is not fixed.

@LucScu
Copy link

LucScu commented Sep 12, 2017

If this issue is not yet fixed, why is it signed as closed?

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Sep 12, 2017
@Brigel
Copy link

Brigel commented Sep 14, 2017

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

magento-engcom-team pushed a commit that referenced this issue Dec 18, 2018
Fixed issues:
  - MAGETWO-97161 Static tests failed on mainline (2.3-develop)
@pmonosolo
Copy link

Its 2020 and the issue is still there. Tested on 2.3.3 CE

@live4soccer7
Copy link

I'm on 2.3.5-p2 and the issue is still there.

@Jehangir-Wahid
Copy link

Jehangir-Wahid commented Nov 18, 2020

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.

@wb-magma
Copy link

wb-magma commented Feb 8, 2021

I'm on 2.4.1 and the issue is still there.

@pbaum83
Copy link

pbaum83 commented Feb 10, 2021

Can confirm, running 2.4.1 also and this bug has been causing us some issues as well.

@live4soccer7
Copy link

How can we get this re-opened? It is definitely still an issue on 2.4.1. I have not tried it yet on 2.4.2.

@hostep
Copy link
Contributor

hostep commented Feb 10, 2021

It's probably worth opening a new ticket. Tickets which got closed 5 years ago often no longer get attention even if people continue to comment on them. So opening a new ticket with exact steps of how to reproduce is probably a better idea if you want to see a fix for this one day :)

@pmonosolo
Copy link

pmonosolo commented Feb 10, 2021

How can we get this re-opened? It is definitely still an issue on 2.4.1. I have not tried it yet on 2.4.2.
Just don't use the uninstall cli command. Many plugin vendors don't even write the Uninstall scripts.

From what I understand, uninstall scripts require rolling back all the data, deleting tables and so on. I would not recommend using it as Uninstall script is probably the last thing plugin devs look at if they do at all (I have yet to see a commercial plugin that has an uninstall script) .

Just go into your composer.json and remove the line for the plugin under "require" and then run composer update.

@tschallacka
Copy link

Magento calls composer in a self contained bufferedoutput, hiding all the output. This hides that it wants the authentication keys for repo.magento.com.

To solve this issue, in your root magento folder you need to add auth.json as a new file, by copying auth.json.sample.
Add your magento public key as username and your private key as password in the json.
Add auth.json to your .gitignore

Now run the command again. It should work now.

@Jehangir-Wahid
Copy link

Jehangir-Wahid commented May 5, 2021

Hi,

We can't wait for magento to solve this for us, as it is neglected for so long and we have to do it on our own.

@hostep @pbaum83 @wb-magma @live4soccer7 @tschallacka and @pmonosolo please refer to my solution posted here.

Maybe it helps you.

tschallacka added a commit to tschallacka/magento2 that referenced this issue May 5, 2021
When auth.json is not found, an FileNotFoundException is thrown.
This is to fix issue magento#3544
This will prevent workarounds like described at https://blog.tschallacka.de/2021/05/binmagento-moduleuninstall-never.html
@tschallacka
Copy link

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 #32955

@dharake
Copy link

dharake commented Sep 5, 2021

@tschallacka This did not work for me in 2.4.3 CE. So technically this is still very much a bug.

@Yakamoz-dev
Copy link

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.

@Jehangir-Wahid
Copy link

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.

Hi there,

Please check each and every step mentioned in my solution. Most probably, you are missing something.

Thanks

@BernardRobbins
Copy link

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

@antonioste
Copy link

but in the auth.json file, the "key" fields must be with "and <>?

Or just with ""?

@Jehangir-Wahid
Copy link

but in the auth.json file, the "key" fields must be with "and <>?

Or just with ""?

Just with ""

@antonioste
Copy link

a lot of try, don't work for me :(

@Jehangir-Wahid
Copy link

a lot of try, don't work for me :(

Have you tried my solution?

@antonioste
Copy link

a lot of try, don't work for me :(

Have you tried my solution?

SURE!

@Jehangir-Wahid
Copy link

a lot of try, don't work for me :(

Have you tried my solution?

SURE!

Try it and please don't miss a single step in that solution.

I hope it works for you.

@antonioste
Copy link

I've add my key in auth.json (no github)
and not work :(

@Henrik41
Copy link

Henrik41 commented Apr 7, 2023

It's 2023 and I have the same issue. I installed a module from a repo which is not mine. Impossible to move along and uninstall it as I get stuck at Removing code from Magento codebase:...

I tried to use the credential from Github but since the module that was taken from another repro it doesn't work!

Can't believe that I cannot remove a module just like that. Anyone has a solution to this?

@antonioste
Copy link

antonioste commented Apr 7, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update
Projects
None yet
Development

Successfully merging a pull request may close this issue.