The problem: packages.drupal.org broken
I was starting my weekly work for the Drupal GraphQL module by the customary composer update --prefer-source -vvv command, ready to watch composer spit out some hundred lines sipping my coffee, but this time something turned out to be wrong:
OK, so packages.drupal.org is down for now. How can we work around this ?
The diagnostic
By default, most of my Drupal 8 project (aren't yours ?) are either based on drupal-composer/drupal-project for actual projects, or a slightly modified drupal/drupal when working on Drupal core or contrib modules like GraphQL. This was the case of the latter model, done by adding specific repositories entries to core composer.json, like:
The explicit vcs entry on top is to enable me to work on my custom fork of the module (from which I send pull requests), no problem here. The issue is with the bottom one, used to download the other package in this project, specifically devel.
When working with such composer repositories, what Composer does is fetch a packages.json path below the url parameter, in this case
https://packages.drupal.org/8/packages.json. That files is a list of data providers, basically one more level of metadata about available repositories and distributions (releases), looking like this:
Composer will then download from each of these providers in turn, hence the URL displayed as returning a 404 at the top of this story. Sure enough, manual checking of the URL returned a 404, even with a cache-buster query added.
Sure enough, the issue was already mentioned on IRC on #drupal : what could be done at this point without being able to touch packages.drupal.org itself ?
The solution: skip one layer
Actually, the answer is already present in the existing repositories clause: vcs-type repositories do not need a "directory"-type service like Packagist or packages.drupal.org, because in essence what these directories do is provide a way to locate sources and dists. But vcs provide the same service, with the limitation that they have to be listed for each project. So let us skip the composer directory and list devel's repository directly:
Now, a composer require drupal/devel --prefer-source -vvv works normally, no longer needing to parse the broken directory:
Time to return to actual work :-)
Thanks for the great
Thanks for the great tutorial, Frederic.
Anyone looking for a tutorial on how to install and configure Drupal 8 with PostgreSQL may find this article useful: https://www.rosehosting.com/blog/how-to-install-drupal-with-postgresql-…