3

Recently we ran into an issue where the Focal Point module has a dependency on a specific version of the CropAPI module. Since composer is installing these modules directly from git, they dont have the version numbers that were added to the .info file by the drupal.org packaging scripts. This cause the focal point module to fail during enable.

Has anyone else solved this?

1
  • Thank you for this awesome module, I use it all the time.
    – No Sssweat
    Nov 18, 2016 at 1:11

4 Answers 4

4

I am using https://packagist.drupal-composer.org/ as Packagist repository for Drupal modules, and I get the version information inside the .info.yml file of the modules I require with composer require.

I first added the new repository with composer config repositories.drupal composer https://packagist.drupal-composer.org/. After, I can add any modules, for example the Focal Point module with a command like the following.

composer require drupal/focal_point 8.1.*@dev

The command install the module and its dependencies, producing the following output.

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing drupal/crop (8.1.0)
    Downloading: 100%         

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing drupal/focal_point (8.1.0-beta3)
    Downloading: 100%         

> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
drupal/crop suggests installing drupal/media_entity (Required by drupal/crop_media_entity)
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess

If then I check the content of modules/focal_point/focal_point.info.yml and modules/crop/crop.info.yml, I get the following output.

name: Focal Point
type: module
description: Allows users to specify the focal point of an image for use during cropping.
# core: 8.x
package: Images
# version: VERSION
test_dependencies:
  - crop
dependencies:
  - image
  - crop (>=8.x-1.0-alpha2)

# Information added by Drupal.org packaging script on 2016-09-01
version: '8.x-1.0-beta3'
core: '8.x'
project: 'focal_point'
datestamp: 1472695440
name: Crop API
description: 'Provides storage and API for image crops.'
# core: 8.x
package: Media
type: module
dependencies:
  - image
  - user

# Information added by Drupal.org packaging script on 2016-05-25
version: '8.x-1.0-rc1'
core: '8.x'
project: 'crop'
datestamp: 1464160143

In both the cases, the information added from the Drupal.org packaging script is present for both the modules (the one I directly required, and it's dependency). I am using this method for all the module I need in my site, and I have never had problems with the version strings.
To update the modules, I just run composer update, and Composer updates all the modules with a new version that respects the restriction I set for each module.

2

This is a known issue, only tagged releases contain a version number. Dev-releases are directly retrieved via git. You can you the Composer deploy module (https://www.drupal.org/project/composer_deploy) to read version numbers for dev releases from composer metadata. Composer deploy has no Config UI. You have to configure the location by yourself. (http://cgit.drupalcode.org/composer_deploy/tree/config/install/composer_deploy.settings.yml)

1
  • But a not tagged release (1.x-dev) still contains the packaging version number in the info.yml file IF NOT installed with composer and downloaded as tar.gz or zip. So this is a composer problem, not a problem of not tagged releases. Or not?
    – drupalfan
    Mar 11, 2021 at 10:36
0

There is a Composer plugin which adds version information to Drupal modules, much like the packaging script:

https://github.com/drupal-composer/info-rewrite

0

Make sure you don't have "preferred-install": "source" present in config of composer.json. In my case, due to this config it was directly cloning the drupal projects from git instead of downloading the tagged package.

1
  • But if I am using the --prefer-dist option the problem still existis.
    – drupalfan
    Mar 11, 2021 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.