When using a composer workflow the diff module is never installed. Then the following exception is thrown: Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "acquia_contenthub.import_entity_manager" has a dependency on a non-existent service "diff.entity_comparison".

Comments

droath created an issue. See original summary.

droath’s picture

Status: Active » Needs review
it-cru’s picture

Priority: Normal » Critical

Patch looks fine. But how we can manage to update a site with installed Acquia Contenthub module?

After module update I have no chance to install missing diff module. In CI deploy process you have sometimes no chance to do a two step update path.

Fatal Error after acquia_contenthub module update:

The website encountered an unexpected error. Please try again later.
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "acquia_contenthub.import_entity_manager" has a dependency on a non-existent service "diff.entity_comparison". in Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences() (line 58 of /vagrant_data/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php).
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array) (Line: 42)
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processDefinition(Object) (Line: 36)
Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->process(Object) (Line: 104)
Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object) (Line: 590)
Symfony\Component\DependencyInjection\ContainerBuilder->compile() (Line: 1263)
Drupal\Core\DrupalKernel->compileContainer() (Line: 866)
Drupal\Core\DrupalKernel->initializeContainer() (Line: 461)
Drupal\Core\DrupalKernel->boot() (Line: 651)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Raised to critical because a module update could break your complete site!

webflo’s picture

StatusFileSize
new455 bytes
it-cru’s picture

Merge both patches

scor’s picture

When using a composer workflow the diff module is never installed.

Does this happen when installing the module the first time on a new site, or does this only happen when upgrading from 1.3 or below to 1.4 or above? (1.4 is when the diff module became a dependency).

webflo’s picture

It happens in the update path from 1.3 or below to 1.4

scor’s picture

Am I the only one to get confused that we have to duplicate the dependency on diff in the composer.json file, when we have it already in the .info.yml file? As far as I can tell, this is only required for sites upgrading to 1.4 or above, but not for new sites installing content hub for the first time. I'm happy to commit this patch, I'm just trying to understand why this is required, and also for future reference if we ever need to add a new dependency again later on.

Edit: https://www.drupal.org/docs/8/creating-custom-modules/let-drupal-8-know-... indicates that the dependencies in your .info.yml file are "A list of other modules your module depends on.", but nowhere does it say that they also have to go into composer.json. Additionally, https://www.drupal.org/docs/8/creating-custom-modules/add-a-composerjson... does not mention anything about .info.yml, and says that composer.json is where "You may optionally define external dependencies for your module in composer.json." So the way I read both these pages is that .info.yml is for d.o module dependencies, and composer.json is for external composer dependencies. As a result, I see the diff module as being listed in the .info.yml file only because it's a Drupal module.

webflo’s picture

The change in the composer.json is not required at all. The composer endpoints from drupal.org take care of it. Composer should add diff as dependency automatically if you update from 1.3 to 1.4, because it is as unmet dependency. http://packages.drupal.org/8 shows the dependency on diff already. You can verify it via "composer info --all drupal/acquia_contenthub 1.4.0".

The patch in #4 is required because diff is a new dependency of acquia_contenthub and has been introduced after the initial installation.

scor’s picture

Status: Needs review » Needs work

@webflo I've tried to test your patch in #4, that is just the update function without the composer change. I've confirmed diff is added and downloaded when running composer require drupal/acquia_contenthub:1.4.

However I'm not able to upgrade from 1.3 to 1.4 seamlessly when applying the patch for the update function. Here are the steps I took:

$ composer require drupal/acquia_contenthub:1.4
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing sunra/php-simple-html-dom-parser (v1.5.2)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing ezyang/htmlpurifier (v4.8.0)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing caxy/php-htmldiff (v0.1.3)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing mkalkbrenner/php-htmldiff-advanced (0.0.8)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing drupal/diff (1.0.0-rc1)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Removing drupal/acquia_contenthub (1.3.0)
  - Installing drupal/acquia_contenthub (1.4.0)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess
~/Sites/devd.../drupal-8.2.6-1 $ drush ev "\Drupal::service('module_installer')->install(['diff']);"
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                      [error]
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "acquia_contenthub.import_entity_manager" has a dependency on a non-existent service "diff.entity_comparison". in Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences() (line 58 of /Users/stephane.corlosquet/Sites/devdesktop/drupal-8.2.6-1/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php).

In the above I ran the same code manually, and it failed. If I apply the patch after running the composer command, and then run drush updb, I get the same error. @webflo what steps did you take for your update function to actually work?

grasmash’s picture

FYI, I resolved this issue on my own installation by downgrading to acquia_contenthub 1.3, clearing caches, manually installing the diff module, then upgrading to 1.5.

webflo’s picture

@scor "drush ev" does a full Drupal bootstrap. It should work if you apply the patch and run "drush updb".

scor’s picture

@webflo then I don't know why it's not working for me on a brand new site:

$ composer require drupal/acquia_contenthub:1.3
$ drush en -y acquia_contenthub
$ composer require drupal/acquia_contenthub:1.4
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing sunra/php-simple-html-dom-parser (v1.5.2)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing ezyang/htmlpurifier (v4.9.1)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing caxy/php-htmldiff (v0.1.3)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing mkalkbrenner/php-htmldiff-advanced (0.0.8)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing drupal/diff (1.0.0-rc1)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Removing drupal/acquia_contenthub (1.3.0)
  - Installing drupal/acquia_contenthub (1.4.0)
    Loading from cache

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess
$ curl https://www.drupal.org/files/issues/2851258-4.patch|patch -d modules/acquia_contenthub/
patching file acquia_contenthub.install
$ drush updb
exception 'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException' with message 'The service "acquia_contenthub.import_entity_manager" has a dependency on a non-existent service "diff.entity_comparison".' in  [error]
/Users/stephane.corlosquet/Sites/devdesktop/drupal-8.2.6ch14/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:58
drupalninja99’s picture

I was able to install the diff module through the UI which gave me an error but still "worked". That let me proceed with other steps (cim/updb). Not ideal but it did work. I think for now the workaround is to enable the diff module prior to upgrade.

scor’s picture

Status: Needs work » Closed (outdated)

This is outdated and I would not expect people to still have issues with this.