Strange composer error & troubleshooting

July 6, 2018

Submitted by twfahey on Fri, 07/06/2018 - 08:50

Recently, I was working on a D8 codebase and getting a pesky error anytime I tried to invoke a composer command:


Just to capture that error in text:

  Plugin composer/installers is missing a require statement for a version of the composer-plugin-api package.

This composer error was preventing me from doing anything useful, and googling for the answer wasn't producing an instantaneous answer.

The composer.json didn't have any special data, it was the "off the shelf" version from Drops 8 (Pantheon's version of Drupal 8). I tried copying over a composer.json from another Drops 8 project that was working properly. Same issue. I tried removing the composer.lock, no change. Then, as I started thinking about how to put things back to a fresh state, it dawned on me to try simply removing the entire `/vendor` directory. Voila! Everything is back to normal. I can successfully run `composer install` and everything completed normally.

To sum up: When having weird composer problems, removing `/vendor` is a quick, easy thing to try in the troubleshooting process.