Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chandan Chaudhary created an issue. See original summary.

Chandan Chaudhary’s picture

Chandan Chaudhary’s picture

Assigned: Chandan Chaudhary » Unassigned
Status: Active » Needs review
borisson_’s picture

+++ b/composer.json
@@ -2,5 +2,17 @@
+  "require-dev": {

why are these in require-dev, shouldn't this be in require?

Chandan Chaudhary’s picture

it was typo error, its better to have require instead of require-dev

Please find the updated patch.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community
miscellainiac’s picture

Hi,

I'd like to point out that by putting these requirements in the composer.json, whenever I run composer drupal-update I get both ctools and token downloaded to my modules folder...which is not what I want since I put all contrib modules in a contrib subfolder under modules. I already had ctools and token there, but running composer drupal-update I get a second copy of each module.

If this needs to be a separate bug, I can log it, but figured the information belonged here.

Berdir’s picture

Category: Support request » Task

Yes, that's a problem specific to composer_manager, which is now deprecated and it is recommend to use composer directly to install modules. See https://www.drupal.org/node/2404989.

That said we recently removed the modules because previously, we hade drupal-packagist specific versions in there. Currently dependencies are auto-generated, but maybe only if there is no file at all.

I still don't know for sure what the process will be exactly, and if composer.json files should manually be added or not, at least for modules that do not require any non-drupal dependencies. So, waiting for now with committing this.

Mixologic’s picture

Status: Reviewed & tested by the community » Needs work

Module maintainers do not need composer.json files to express dependencies on other drupal modules, unless, for some reason having that module on the filesystem allows them to use it without it being a hard dependency (say, a module provides a cache backend class or something).

They can also use them if they want to have a more semverish compliant dependency specification. But for something like this where there are just *'s, you'd be fine without one.

Generally, unless you need external dependencies, you probably do not need a composer.json for your module.

+++ b/composer.json
@@ -2,5 +2,17 @@
+    "drupal/ctools": "8.*",
+    "drupal/path": "8.*",
+    "drupal/token": "8.*"

Do *not* include 8. in composer dependencies. That versioning is deprecated and will not work with packages.drupal.org/8

That being said, *please* namespace your dependencies in your info.yml files, http://cgit.drupalcode.org/pathauto/tree/pathauto.info.yml#n7 should be ctools:ctools, drupal:path, and token:token.

morsok’s picture

Assigned: Unassigned » morsok
morsok’s picture

Assigned: morsok » Unassigned
Status: Needs work » Needs review
FileSize
737 bytes

Following #9 I updated the namepaces in the .info.yml and removed the composer.json so D.O auto-generates one with dependencies.

Berdir’s picture

Title: Composer file should have the module dependencies » Remove composer.json and namespace dependencies

  • Berdir committed 05a0bc5 on 8.x-1.x authored by morsok
    Issue #2766303 by Chandan Chaudhary, morsok: Remove composer.json and...
Berdir’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Status: Closed (fixed) » Needs work

The last submitted patch, 11: composer_file_should-2766303-11.patch, failed testing.

Berdir’s picture

Status: Needs work » Closed (fixed)
Xano’s picture

I recommend adding this back, as per Composer's own instructions. Without composer.json, Drupal extensions can only ever be installed through a Packagist service, and their code can only be autoloaded after Drupal has been bootstrapped, neither of which is a good thing, as extensions may need to be pulled in from other sources (VCS or path repositories), and code may need to be loaded without a Drupal bootstrap, such as during Behat runs.