drush pm-uninstall google_analytics -ydrush en google_analytics -y
[error] Error: Call to a member function grantPermission() on null in google_analytics_install() (line 17 of /var/www/html/web/modules/contrib/google_analytics/google_analytics.install) #0 [internal function]: google_analytics_install()
#1 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(417): call_user_func_array()
#2 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(357): Drupal\Core\Extension\ModuleHandler->invoke()
#3 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install()
#4 /var/www/html/vendor/drush/drush/src/Drupal/Commands/pm/PmCommands.php(103): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install()
#5 [internal function]: Drush\Drupal\Commands\pm\PmCommands->enable()
#6 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
#7 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#8 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#9 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process()
#10 /var/www/html/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#11 /var/www/html/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
#12 /var/www/html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#13 /var/www/html/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#14 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run()
#15 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun()
#16 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run()
#17 /var/www/html/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/html/v...')
#18 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main()
#19 /usr/local/bin/drush(14): require('phar:///usr/loc...')
#20 {main}.
[07-Feb-2023 15:53:39 UTC] Error: Call to a member function grantPermission() on null in /var/www/html/web/modules/contrib/google_analytics/google_analytics.install on line 17 #0 [internal function]: google_analytics_install()
#1 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(417): call_user_func_array()
#2 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(357): Drupal\Core\Extension\ModuleHandler->invoke()
#3 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install()
#4 /var/www/html/vendor/drush/drush/src/Drupal/Commands/pm/PmCommands.php(103): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install()
#5 [internal function]: Drush\Drupal\Commands\pm\PmCommands->enable()
#6 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
#7 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#8 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#9 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process()
#10 /var/www/html/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#11 /var/www/html/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
#12 /var/www/html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#13 /var/www/html/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#14 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run()
#15 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun()
#16 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run()
#17 /var/www/html/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/html/v...')
#18 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main()
#19 /usr/local/bin/drush(14): require('phar:///usr/loc...')
#20 {main}
Error: Call to a member function grantPermission() on null in google_analytics_install() (line 17 of /var/www/html/web/modules/contrib/google_analytics/google_analytics.install).
[warning] Drush command terminated abnormally.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | google_analytics-check-role-exists-on-install-3340020-9.patch | 1.08 KB | stefan lehmann |
| #8 | Screenshot 2023-08-08 at 17.28.40.png | 159.27 KB | vinlaurens |
| #6 | Screenshot 2023-02-08 at 7.34.19 PM.png | 67.71 KB | arunkumark |
Issue fork google_analytics-3340020
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
vacilando commentedComment #3
vacilando commentedComment #4
vacilando commentedSolved by deleting and adding role "authenticated". Not sure why it was needed.
In any case, I suggest making
$role = Role::load('authenticated');(https://git.drupalcode.org/project/google_analytics/-/blob/4.x/google_an...)conditional, as it's not guaranteed that every system will have a role with that name.
Comment #5
vacilando commentedComment #6
arunkumarkVerified the issue with the latest version of Drupal. Unable to replicate the issue. Attached screenshot of the successful installation and uninstall of the module.
Drupal core: 10.0.3
Google Analytics: 4.0.2
Comment #7
chriseikelboom commentedI had a similar situation where the module was enabled on a different develop environment (most likely with authenticated role present in the database).
Than when I was setting up a new develop environment (with recent database from production without authenticated role), It caused an error on the drush deploy.
I think you can replicate the situation by first removing the authenticated role and than installing the module.
Comment #8
vinlaurens commentedUnfortunately, I was able to reproduce this using a pipeline in Gitlab which does a fresh site install with drush.
Drupal version: 10.1.2
Google Analytics: 4.0.2
PHP: 8.1
Comment #9
stefan lehmannWe have the same issue as vinlaurens with the same Stack. This error comes up as part of the Gitlab CI pipeline test process. A clean install of Drupal but with an existing configuration of modules which have to be installed etc.
Here the last command that leads to this error. I assume the user role just doesn't exist yet at the point when this module is installed.
I just wrote a little check if that user role was successfully loaded.
Comment #10
stefan lehmannComment #11
stefan lehmannFunny I just realised after doing it last weekend that this is just a duplicate of https://www.drupal.org/project/google_analytics/issues/3373921
I basically created exactly the same patch as the guy in that ticket. :-)
Comment #12
stefan lehmann