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

[2.1.0] module:uninstall can remove code it uses itself #5797

Closed
hostep opened this issue Jul 25, 2016 · 9 comments
Closed

[2.1.0] module:uninstall can remove code it uses itself #5797

hostep opened this issue Jul 25, 2016 · 9 comments
Labels
bug report Component: Setup Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release

Comments

@hostep
Copy link
Contributor

hostep commented Jul 25, 2016

Preconditions

  1. Figure out a way to travel back and forth in time (I added some hints)
  2. We use composer version 1.1.3 by adding this to our composer.json file: "composer/composer": "1.1.3 as 1.0.0-beta1",, due to another bug, but I think it won't really matter which version is being used
  3. PHP 7.0.9
  4. Magento 2.1.0

Steps to reproduce

  1. Travel back in time to when symfony/process version 2.8.8 wasn't released yet (hint: try to downgrade to version 2.8.7 of the module after step 2)
  2. Install Magento 2.1.0 using composer
  3. Install a third party module using composer (composer require, bin/magento setup:upgrade, ...)
  4. Travel back to the current time when symfony/process version 2.8.8 was released (hint: don't do anything in this step)
  5. Uninstall the module you installed in step 3 by using bin/magento module:uninstall

Expected result

  1. Module is uninstalled without a problem

Actual result

  1. When Magento tries to uninstall the module using composer, it also at the same time tries to update symfony/process from version 2.8.7 to 2.8.8 for some strange reason. And since symfony/process is being used by the module:uninstall command, the command stops running.
  2. Console output:
➜ php bin/magento module:uninstall Vendor_MyModule
You are about to remove code and/or database tables. Are you sure?[y/N]y
Enabling maintenance mode
You are about to remove a module(s) that might have database data. Do you want to remove the data from database?[y/N]N
Removing Vendor_MyModule from module registry in database
Removing Vendor_MyModule from module list in deployment configuration
Removing code from Magento codebase:
Command "remove" failed: Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing vendor/my-module (v1.0.11)
Removing Vendor/MyModule
  - Removing symfony/process (v2.8.7)

Removal failed, reverting ./composer.json to its original content.



  [ErrorException]
  include(/Users/me/Projects/my-project/vendor/composer/../symfony/process/ExecutableFinder.php): failed to open stream: No such file or directory



remove [--dev] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--no-update-with-dependencies] [--ignore-platform-reqs] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [packages1] ... [packagesN]



Please disable maintenance mode after you resolved above issues

Bit of debugging

It turns out at the step when the composer remove step is executed, this happens:

➜ composer remove --working-dir=/Users/me/Projects/my-project vendor/my-module
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing vendor/my-module (v1.0.11)
Removing Vendor/MyModule
  - Removing symfony/process (v2.8.7)
  - Installing symfony/process (v2.8.8)
    Loading from cache

Package fabpot/php-cs-fixer is abandoned, you should avoid using it. Use friendsofphp/php-cs-fixer instead.
Writing lock file
Generating optimized autoload files

So for some reason symfony/process gets updated to the latest version while removing another module which has no direct dependencies on symfony/process. But this particular module has some dependencies on some magento modules which in itself will probably have dependencies on symfony/process module.

I think you can work around this if you add the --no-update-with-dependencies switch, since that won't update symfony/process:

➜ composer remove --no-update-with-dependencies --working-dir=/Users/me/Projects/my-project vendor/my-module
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing vendor/my-module (v1.0.11)
Removing Vendor/MyModule
Package fabpot/php-cs-fixer is abandoned, you should avoid using it. Use friendsofphp/php-cs-fixer instead.
Writing lock file
Generating optimized autoload files

Please review thoroughly, because this seems to be something which can turn out to be quite complicated!
Also: I haven't tested my solution with that --no-update-with-dependencies flag yet.

For other people running into this problem: first update all your dependencies to the latest version by just running composer update (hint you can run composer update --dry-run to preview what it will do first) and only after your dependencies are updated, run the module:uninstall command.

@hostep
Copy link
Contributor Author

hostep commented Aug 3, 2016

Possible related issue: #3544

@shiftedreality
Copy link
Member

Hi @hostep

Thank you for deep investigation and reporting.
We've create internal ticket MAGETWO-58132 to fix this issue.

@shiftedreality shiftedreality added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 7, 2016
mmansoor-magento pushed a commit that referenced this issue Sep 23, 2016
Fixed issues:
* MAGETWO-57820: [GITHUB] php bin/magento i18n:pack creates unwanted dir #6260
Bug - P1
* MAGETWO-58337: [Github] Duplicated & missing product rows in system product export #4531
* MAGETWO-58289: [Github] Product URL Key not automatically generating during import #5128
* MAGETWO-58134: [GitHub] Products became “out of stock” after update from 2.0.7 to 2.1.0 #5222
* MAGETWO-58132: [GitHub] module:uninstall can remove code it uses itself #5797
* MAGETWO-58236: Sync requirements of composer.json of Sample-data with mainline
@mattcoz
Copy link

mattcoz commented Apr 14, 2017

I'm unable to upgrade from 2.1.3 to 2.1.6 because of this error. It removes symfony/process and then immediately throws the error. It happens during the "composer update" command, so that doesn't help me.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Component: Setup labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@hostep, thank you for your report.
The issue is already fixed in 2.2.0

@sidolov
Copy link
Contributor

sidolov commented Sep 22, 2018

Hi @hostep. Thank you for your report.
The issue has been fixed in #18002 by @Thundar in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@sidolov
Copy link
Contributor

sidolov commented Sep 26, 2018

Hi @hostep. Thank you for your report.
The issue has been fixed in #18205 by @mage2pratik in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@sidolov sidolov added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Sep 26, 2018
mmansoor-magento pushed a commit that referenced this issue Oct 15, 2020
@Eddcapone
Copy link

Eddcapone commented Feb 24, 2021

I have a similar issue in Magento 2.4.2

@hostep
Copy link
Contributor Author

hostep commented Feb 25, 2021

@Eddcapone: please open a new issue, the fix mentioned above is still in Magento 2.4.2 so you are probably running against a new bug.

@haijerome
Copy link

apparently I ran composer remove vendor/module --ignore-platform-reqs to uninstall the module that I had installed through composer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Setup Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

No branches or pull requests

9 participants