Closed giloliveira-nmi closed 3 years ago
@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()
1 /path/to/grav-admin/system/src/Grav/Console/GpmCommand.php(41): Grav\Console\Gpm\UninstallCommand->serve()
2 /path/to/grav-admin/vendor/symfony/console/Command/Command.php(255): Grav\Console\GpmCommand->execute()
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
I think it’s just the type not generic enough, should be expecting any BasePackage not just RemotePackage types.
Yeah, fixing...
Can you try if the fixed code works for you?
$ 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
Ok, that was unexpected. I fixed clearcache already elsewhere, but looks like I need to do it here, too.
@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/php@7.3/7.3.26_1/share/php@7.3/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
That error should be fixed, too.
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'
Should be fixed in #3207
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.