-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Resolving module:uninstall hanging without response #32955
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
base: 2.4-develop
Are you sure you want to change the base?
Resolving module:uninstall hanging without response #32955
Conversation
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
Hi @tschallacka. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
I'm seeing a cross at the functional tests, yet I don't see any failing tests, only one yellow test that is wholly unrelated to this pr. Is that test broken? Also, I signed the document, when wil the status update? |
private function failOnMissingAuthJson() | ||
{ | ||
$auth_json_path = BP . DIRECTORY_SEPARATOR . 'auth.json'; | ||
if (!file_exists($auth_json_path)) { | ||
$error_message = sprintf('auth.json at %s could not be found. Refer to https://devdocs.magento.com/guides/v2.4/install-gde/prereq/dev_install.html#authentication-file how to install this file.', $auth_json_path); | ||
throw new FileNotFoundException($error_message); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure it's ok to make the auth.json mandatory? I don't think so, as we might set the credentials globally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have set my auth.json globally, via ~/.composer/auth.json and that works fine when a manual ~ composer update
or ~ composer remove xxx
is run. But when this composer sub process is started up, via the ~ bin/magento module:uninstall
it doesn't read from ~/.composer/auth.json for whatever reason, which then leads to the bug as is set out in the related issue as it prompts for the password behind the scenes. It only continues on when the data is present in the auth.json file.
I've made a dummy repo here of the plugin that demonstrates the issue. https://github.com/tschallacka/mage2-dummy-test
When there is an auth.json in the root it runs fine, as is highlighted in my blog post. If there is no auth.json in the root, it hangs and gives issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the issue is related to incorrect composer usage, so it's not reading the global auth.json file. The correct fix should fix this inconsistent behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be amenable to make a more comprehensive test if you could point me to where the wrapped composer instance tries to read auth.json and when it fails, if you have a better suggested course of action, to prevent the hanging screen i'm open. Just an error message like in my plugin perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know exactly where that code located, but it looks like the composer remove logic is here:
magento2/lib/internal/Magento/Framework/Composer/Remove.php
Lines 41 to 52 in 8b9fff5
public function remove(array $packages) | |
{ | |
$composerApplication = $this->composerApplicationFactory->create(); | |
return $composerApplication->runComposerCommand( | |
[ | |
'command' => 'remove', | |
'packages' => $packages, | |
'--no-update-with-dependencies' => true, | |
] | |
); | |
} |
Please set the breakpoint on this code and debug deeper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the issue is related to incorrect composer usage, so it's not reading the global auth.json file. The correct fix should fix this inconsistent behavior.
totally agree, that composer should read auth.json anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ihor-sviziev if you read my blog post at https://blog.tschallacka.de/2021/05/binmagento-moduleuninstall-never.html you can follow my tracking process how I traced the composer path related to the output. I never delved into the actual process of composer itself as it takes so many twists and turns that after 15 minutes of pressing step into I still wasn't at the auth.json search steps. I must admit I kinda gave up.
Hi @tschallacka, thank you for your contribution! |
@magento run Functional Tests B2B |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
2.4.3 CE. Even with correct utilisation of auth.json the command bin/magento module:uninstall still hangs indefinitely at the code removal step. |
2.4.3-p1 CE and I'm hit by this bug. I have auth.json populated with access credentials. Any solution, workaround available? |
This fix is based on #3544
Basically, when Magento command
bin/magento module:uninstall Module_Name
is called it will hang indefinitely, even for half an hour. The only way to exit is to CTRL +C out of it.I posted my research in this issue here: https://blog.tschallacka.de/2021/05/binmagento-moduleuninstall-never.html but it boils down that when auth.json is not found in the Magento root dir, composer will prompt for the access keys to repo.magento.com, but as the output is contained in a BufferedOutput that doesn't output to STDOUT this isn't visible.
My proposed fix, before initiating the uninstall via composer, check if auth.json exists in the root dir.
When auth.json is not found, an FileNotFoundException is thrown, adding a reference to https://devdocs.magento.com/guides/v2.4/install-gde/prereq/dev_install.html#authentication-file so they can resolve the issue.
For testing have a module that registers a custom attribute that you remove with an uninstaller, with a missing auth.json in the Magento root directory.
Description (*)
Added a private method ModuleUninstaller::failOnMissingAuthJson().
This method tests whether auth.json exists in the Magento root dir. When it is not found it throws a meaningful error message with a reference to the developer documentation.
This method is called in ModuleUninstaller::uninstallCode()
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
bin/magento module:enable Test_Dummy && bin/magento setup:upgrade && bin/magento module:disable Test_Dummy && bin/magento module:uninstall Test_Dummy
Questions or comments
Contribution checklist (*)