Service is missing even though module is enabled

Created on 3 January 2023, over 1 year ago
Updated 22 December 2023, 6 months ago

Problem/Motivation

I have a multi-site Drupal platform running Drupal 9.5.0. When attempting to do a new site installation from existing config where flexible permissions is included and group 2.0.0-beta6 is included, I ended up with an error message. The error message itself actually comes after the install has run, a cache-rebuild runs, and then a node access rebuild runs:

> In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
>                                                                                
>   The service "group_permission.calculator" has a dependency on a non-existen  
>   t service "flexible_permissions.chain_calculator".

The actual error is happening after the install. If I try to manually run some other commands after install (not the node access rebuild where I see it initially), I get the error again.

I can login to the site and see that flexible permissions is indeed enabled. Configuration shows that is in sync with code.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: works as designed

Version

9.5

Component
Extension 

Last updated 3 days ago

No maintainer
Created by

🇺🇸United States shelane

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Please reactivate once you've figured out why your container is missing a service that should clearly be there. Moving to core for now as this does not seem like a Group or Flexible Permissions issue.

  • 🇳🇿New Zealand quietone New Zealand

    Changing version per the issue summary.

  • 🇺🇸United States will_frank

    We are experiencing this same issue on Drupal 10.
    I tried installing and enabling drupal/flexible_permissions first
    before installing drupal/group:^2.0
    What we still see is:
    The service "group_permission.calculator" has a dependency on a non-existent service "flexible_permissions.chain_calculator".

  • 🇬🇧United Kingdom Hitby

    Also having this issue with a D9 > D10 upgrade

  • 🇨🇦Canada krina_t

    Running into the same issue.
    Drupal Version: D9
    Upgrading from Group 8.x.1.5 to v2.
    Installed and enabled the Flexible permissions module while being on the group 1.5 version.
    Updated group version to 2.0.1

    Error on running drush commands:
    In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
    The service "group_permission.calculator" has a dependency on a non-existent service "flexible_permissions.chain_calculator".

  • 🇫🇮Finland tonihoo

    I also faced this issue with a D9 > D10 upgrade. However, installing and enabling Flexible permissions first (D9), then making a database dump, and then upgrading (locally) to D10 with Group 2.0 and the new dump -> success.

  • 🇩🇪Germany broon Potsdam

    The issue is always present in (semi-)automated environments where a standardized install script is running.

    Our script essentially does this:

    composer install
    drush cr
    drush updb -y
    drush cr
    drush cim -y
    drush cr
    drush deploy:hook
    drush cr

    If you have i.e. Drupal 9.5.9 with Group 1.5 installed and the new package is pushed to the staged server, composer install will download flexible_permissions. But at this point it will still be disabled. By default, it will only be enable during "drush cim -y" when core.extensions.yml is read and imported.

    However, that's to late as Group module already requires it during the update hooks. Thus, the first update hook actually installs the flexible_permissions module:

    function group_update_9200() {
      \Drupal::service('module_installer')->install(['flexible_permissions'], TRUE);
    }

    Now, the point is, that the install script already fails before that, during the first run of "drush cr". As the Group module is already installed, a cache rebuild will import the *.services.yml files from all enabled modules. And inside groups.services.yml, the system will find this:

      group_permission.calculator:
        class: 'Drupal\group\Access\GroupPermissionCalculator'
        arguments: ['@flexible_permissions.chain_calculator']

    But as flexible_permissions isn't yet enabled, it will fail to find that service.

    With the above default install script, an update of Group 1.5 => 2.x is not possible within one delivery. The only solution I can think of is to put group_permissions into a new submodule which will then be enable alongside flexible_permissions.

  • Status changed to Closed: works as designed 11 months ago
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Judging from #13 it seems like this isn't a problem with Group, but rather how people deploy their projects. Your deployment script should be capable of rolling out a new dependency. I assume running drush updb first should fix your issues

  • 🇩🇪Germany broon Potsdam

    Indeed. There are some alternatives to that.

    I am not sure anymore, why we (need to) run "drush cr" first in our deploy script insertMemeHere("AtThisPointIAmAfraidToAsk"). But if it is important, you can add an extra step before running "drush cr" with Drupal Console:

    drupal config:import:single --directory="config/sync" --file="core.extension.yml"

    This command will only import the core.extension config and thus already enable flexible_permissions. After that, "drush cr" won't fail.

  • This issue is quite frustrating as I'm looking to stage D10... Glad that there are some recent comments though and it's probably just something I am misunderstanding!

    I did find a similar reference for this issue at https://www.drupal.org/project/group/issues/3298788#comment-14661264 🐛 Group 2.0 upgrade path? Fixed which mentions downgrading Group, then installing Flexible_Permissions, then enabling the module...

    That at least gets me passed the main error above for a non-existence dependency described above. But now I get a different and equally confusing error (which might be specific to drupal/group:^1.5) as the following:

    Fatal error: Cannot declare class Drupal\group_test_content\Entity\StringConfig, because the name is already in use in /code/web/modules/contrib/group/src/Entity/StringConfig.php on line 0
    

    My thought at this point is that the Group module just isn't D10 ready given this Flexible_Permissions business.

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    I can assure you Group 2/3 are D10 ready just fine as the automated tests run on D10. If you are having trouble upgrading, try getting it to work locally and then adjust your deployment to do the same steps in the same order.

    There was a similar issue before, but that was fixed in [3298788]

    Check that issue's latest comments on the order people got their upgrade to work in. It often came down to first installing FP and then upgrading to Group 2/3.

  • 🇭🇺Hungary Pasqualle 🇭🇺 Budapest

    The argument should have been made optional to avoid any upgrade issue.
    In groups.services.yml add an extra "?" to the group_permission.calculator service argument, like:

     group_permission.calculator:
        class: 'Drupal\group\Access\GroupPermissionCalculator'
        arguments: ['@?flexible_permissions.chain_calculator']
    

    see: https://symfony.com/doc/current/service_container/optional_dependencies....

    This should allow to enable flexible_permissions module while having this error.

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    That's for minor version upgrades. Major versions are allowed (and expected) to have breaking changes. It's up to the users to read the release notes properly and make sure they enable the new dependency first.

  • 🇧🇷Brazil bsfajardo Porto Alegre, Brazil

    Just wanted to say that #18 just saved me during a deployment. Thank you so much!

  • 🇺🇸United States SiliconValet

    Patch attached of #18 solution

  • 🇮🇳India Gowtham.Boopathiraj

    After applying the #18 patch showing below error in group module 3.2.1 (Drupal 10).

    php Error TypeError: Drupal\group\Access\GroupPermissionCalculator::__construct(): Argument #1 ($chain_calculator) must be of
    type Drupal\flexible_permissions\ChainPermissionCalculatorInterface, nul

  • Pasqualle's comment in #18 saved us. We've spent days on a complicated D9->D10 upgrade and drupal/group broke the site after we manually used composer to update from drupal/group 1.x to 2.x. We found nothing helpful in the release notes.

    The attitude of some developers in this thread is not helpful.

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    We found nothing helpful in the release notes.

    Literally from the top of the release notes:

    New dependency: Flexible permissions

    Download and enable this first before you upgrade: https://www.drupal.org/project/flexible_permissions

    You didn't properly read the release notes and then call people who tell you to read the release notes "not helpful". I thought it was common sense that when moving between major versions of software you'd at least check the release notes instead of bulldozering your way through with Composer and then wondering why things are broken.

Production build 0.69.0 2024