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

GPM Uninstall script stops working after upgrade to 1.7 #3172

Closed
giloliveira-nmi opened this issue Jan 22, 2021 · 10 comments
Closed

GPM Uninstall script stops working after upgrade to 1.7 #3172

giloliveira-nmi opened this issue Jan 22, 2021 · 10 comments
Assignees

Comments

@giloliveira-nmi
Copy link

giloliveira-nmi commented Jan 22, 2021

I've searched around some time but can't seem to find clues to solving this puzzle. After upgrading my GRAV installation to 1.7 through CLI, the bin/gpm uninstall command seems to be broken.

I've tested the command with two plugins: mobile-detect and problems, with the same result for both plugins.

To see what caused the issue, I rolled back some updates of composer packages and GRAV to v1.6. I tested the script after each step and found that it only stopped working after upgrading GRAV to v1.7. I hope someone could point me in the right direction, since it doesn't seem to be a common issue.

Fatal error:  Uncaught TypeError: Grav\Console\Gpm\UninstallCommand::checkDestination(): Argument #2 ($package) must be of type Grav\Common\GPM\Remote\Package, Grav\Common\GPM\Local\Package given, called in wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php on line 118 and defined in wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php:254
Stack trace:
#0 wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php(118): Grav\Console\Gpm\UninstallCommand->checkDestination('problems', Object(Grav\Common\GPM\Local\Package))
#1 wwwroot/system/src/Grav/Console/GpmCommand.php(41): Grav\Console\Gpm\UninstallCommand->serve()
#2 wwwroot/vendor/symfony/console/Command/Command.php(255): Grav\Console\GpmCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 wwwroot/vendor/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 wwwroot/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Grav\Console\Gpm\UninstallCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 wwwroot/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 wwwroot/bin/gpm(49): Symfony\Component\Console\Application->run()
#7 {main}
  thrown in wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php on line 254
@pamtbaau
Copy link
Contributor

pamtbaau commented Jan 22, 2021

@mahagr, I've noticed before that if any plugin fails after upgrade, the CLI will not work anymore and throws an Exception.

For example:

  • $ bin/gpm install cadphp

  • $ bin/gpm uninstall cadphp

    Preparing to uninstall Cadphp [v1]
    Checking destination... PHP Fatal error: Uncaught TypeError: Argument 2 passed to Grav\Console\Gpm\UninstallCommand::checkDestination() must be an instance of Grav\Common\GPM\Remote\Package, instance of Grav\Common\GPM\Local\Package given, called in /path/to/grav-admin/system/src/Grav/Console/Gpm/UninstallCommand.php on line 118 and defined in /path/to/grav-admin/system/src/Grav/Console/Gpm/UninstallCommand.php:254
    Stack trace:
    #0 /path/to/grav-admin/system/src/Grav/Console/Gpm/UninstallCommand.php(118): Grav\Console\Gpm\UninstallCommand->checkDestination()
    Update README.md #1 /path/to/grav-admin/system/src/Grav/Console/GpmCommand.php(41): Grav\Console\Gpm\UninstallCommand->serve()
    Fix: error 500 IIS #2 /path/to/grav-admin/vendor/symfony/console/Command/Command.php(255): Grav\Console\GpmCommand->execute()
    Fixed typos/CS #3 /path/to/grav-admin/ven in /path/to/grav-admin/system/src/Grav/Console/Gpm/UninstallCommand.php on line 254

Here is the code for CadPHP: https://github.com/cadjou/grav-plugin-cadphp/blob/master/cadphp.php

@w00fz
Copy link
Member

w00fz commented Jan 22, 2021

I think it’s just the type not generic enough, should be expecting any BasePackage not just RemotePackage types.

@mahagr
Copy link
Member

mahagr commented Jan 22, 2021

Yeah, fixing...

@mahagr
Copy link
Member

mahagr commented Jan 22, 2021

Can you try if the fixed code works for you?

@pamtbaau
Copy link
Contributor

pamtbaau commented Jan 22, 2021

  • $ git clone https://github.com/getgrav/grav .
  • $ bin/grav install
  • $ bin/gpm install cadphp
  • $ bin/gpm uninstall cadphp

Preparing to uninstall Cadphp [v1]
|- Checking destination... ok
|- Uninstalling Cadphp package... ok
'- Success!
PHP Fatal error: require(): Failed opening required '/path/to/site-dev/user/plugins/cadphp/classes/Cadphp.php' (include_path='.:/usr/share/php') in /path/to/site-dev/user/plugins/cadphp/cadphp.php on line 11
PHP Stack trace:
PHP 1. {main}() /path/to/grav-admin/bin/gpm:0
PHP 2. Grav\Console\Application\GpmApplication->run() /path/to/grav-admin/bin/gpm:49
PHP 3. Grav\Console\Application\GpmApplication->doRun() /path/to/grav-admin/vendor/symfony/console/Application.php:149
PHP 4. Grav\Console\Application\GpmApplication->doRunCommand() /path/to/grav-admin/vendor/symfony/console/Application.php:273
PHP 5. Grav\Console\Gpm\UninstallCommand->run() /path/to/grav-admin/vendor/symfony/console/Application.php:1009
PHP 6. Grav\Console\Gpm\UninstallCommand->execute() /path/to/grav-admin/vendor/symfony/console/Command/Command.php:255
PHP 7. Grav\Console\Gpm\UninstallCommand->serve() /path/to/grav-admin/system/src/Grav/Console/GpmCommand.php:41
PHP 8. Grav\Console\Gpm\UninstallCommand->clearCache() /path/to/grav-admin/system/src/Grav/Console/Gpm/UninstallCommand.php:137
PHP 9. Grav\Console\Cli\ClearCacheCommand->run() /path/to/grav-admin/system/src/Grav/Console/ConsoleTrait.php:307
PHP 10. Grav\Console\Cli\ClearCacheCommand->execute() /path/to/grav-admin/vendor/symfony/console/Command/Command.php:255
PHP 11. Grav\Console\Cli\ClearCacheCommand->serve() /path/to/grav-admin/system/src/Grav/Console/GravCommand.php:39
PHP 12. Grav\Console\Cli\ClearCacheCommand->initializePlugins() /path/to/grav-admin/system/src/Grav/Console/Cli/ClearCacheCommand.php:55
PHP 13. Grav\Common\Grav->fireEvent() /path/to/grav-admin/system/src/Grav/Console/ConsoleTrait.php:181
PHP 14. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() /path/to/grav-admin/system/src/Grav/Common/Grav.php:537
PHP 15. Symfony\Component\EventDispatcher\EventDispatcher->callListeners() /path/to/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:73
PHP 16. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() /path/to/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:239
PHP 17. Grav\Plugin\CadphpPlugin->onPluginsInitialized() /path/to/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:264

@mahagr
Copy link
Member

mahagr commented Jan 22, 2021

Ok, that was unexpected. I fixed clearcache already elsewhere, but looks like I need to do it here, too.

@mahagr mahagr removed the fixed label Jan 22, 2021
@giloliveira-nmi
Copy link
Author

@mahagr your fix worked for me as well, as I could successfully uninstall the Problems plugin. @pamtbaau already noticed the issue that arose afterwards, which also happens for me with said plugin. Just fyi

PHP Fatal error:  require(): Failed opening required 'wwwroot/user/plugins/problems/vendor/autoload.php' (include_path='.:/usr/local/Cellar/[email protected]/7.3.26_1/share/[email protected]/pear') in wwwroot/user/plugins/problems/problems.php on line 37
PHP Stack trace:
PHP   1. {main}() wwwroot/bin/gpm:0
PHP   2. Grav\Console\Application\GpmApplication->run() wwwroot/bin/gpm:49
PHP   3. Grav\Console\Application\GpmApplication->doRun() wwwroot/vendor/symfony/console/Application.php:149
PHP   4. Grav\Console\Application\GpmApplication->doRunCommand() wwwroot/vendor/symfony/console/Application.php:273
PHP   5. Grav\Console\Gpm\UninstallCommand->run() wwwroot/vendor/symfony/console/Application.php:1009
PHP   6. Grav\Console\Gpm\UninstallCommand->execute() wwwroot/vendor/symfony/console/Command/Command.php:255
PHP   7. Grav\Console\Gpm\UninstallCommand->serve() wwwroot/system/src/Grav/Console/GpmCommand.php:41
PHP   8. Grav\Console\Gpm\UninstallCommand->clearCache() wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php:137
PHP   9. Grav\Console\Cli\ClearCacheCommand->run() wwwroot/system/src/Grav/Console/ConsoleTrait.php:307
PHP  10. Grav\Console\Cli\ClearCacheCommand->execute() wwwroot/vendor/symfony/console/Command/Command.php:255
PHP  11. Grav\Console\Cli\ClearCacheCommand->initializeGrav() wwwroot/system/src/Grav/Console/GravCommand.php:36
PHP  12. Grav\Common\Processors\InitializeProcessor::initializeCli() wwwroot/system/src/Grav/Console/ConsoleTrait.php:132
PHP  13. Grav\Common\Processors\InitializeProcessor->processCli() wwwroot/system/src/Grav/Common/Processors/InitializeProcessor.php:58
PHP  14. Grav\Common\Processors\InitializeProcessor->initializePlugins() wwwroot/system/src/Grav/Common/Processors/InitializeProcessor.php:150
PHP  15. Grav\Common\Plugins->init() wwwroot/system/src/Grav/Common/Processors/InitializeProcessor.php:376
PHP  16. Grav\Plugin\ProblemsPlugin->autoload() wwwroot/system/src/Grav/Common/Plugins.php:133

@mahagr
Copy link
Member

mahagr commented Feb 1, 2021

That error should be fixed, too.

@giloliveira-nmi
Copy link
Author

giloliveira-nmi commented Feb 3, 2021

Thanks for your effort @mahagr! Unfortunately, I am still getting the same error as before after uninstalling the plugin problems. Tried at 1.7.5 and verified that your latest commit was present in my build. The errors differ though, for different plugins. The plugin error didn't return any issues, but git-sync did return the following. Not sure if it is related.

Fatal error: Uncaught TypeError: Argument 2 passed to Grav\Console\Gpm\UninstallCommand::packageExists() must be an instance of Grav\Common\GPM\Local\Package, instance of Grav\Common\GPM\Remote\Package given, called in /Users/Gil/Sites/Movements/movements/wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php on line 205 and defined in /Users/Gil/Sites/Movements/movements/wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php:303
Stack trace:
#0 /Users/Gil/Sites/Movements/movements/wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php(205): Grav\Console\Gpm\UninstallCommand->packageExists('form', Object(Grav\Common\GPM\Remote\Package))
#1 /Users/Gil/Sites/Movements/movements/wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php(132): Grav\Console\Gpm\UninstallCommand->uninstallPackage('git-sync', Object(Grav\Common\GPM\Local\Package))
#2 /Users/Gil/Sites/Movements/movements/wwwroot/system/src/Grav/Console/GpmCommand.php(41): Grav\Console\Gpm\UninstallCommand->serve()
#3 /Users/Gil/Sites/Movements/movements/wwwro in /Users/Gil/Sites/Movements/movements/wwwroot/system/src/Grav/Console/Gpm/UninstallCommand.php on line 303

On a side note; my IDE (intelephense) seems to point at the lines 205 and 214 with the following notice for $dependencyPackage:

Expected type 'Grav\Common\GPM\Local\Package'. Found 'Grav\Common\GPM\Remote\Package|false'

@mahagr
Copy link
Member

mahagr commented Feb 8, 2021

Should be fixed in #3207

@mahagr mahagr closed this as completed Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants