dxw/phar-install

`composer require google/apiclient` fails

Opened this issue · 1 comments

Running composer require google/apiclient adds an abnormally huge number of files. And this causes problems when phar-install is used as a post-update-cmd.

In a fairly normal theme that requires google/apiclient, if I run composer install --no-dev, I get these results:

% find vendor | wc -l
5055
% find vendor/google | wc -l
4462

(It more than octuples the number of files.)

Here's the error it generates:

Adding file: vendor/google/apiclient-services/Google/Service/Dfareporting/Recipient.php
Adding file: vendor/google/apiclient-services/Google/Service/Dfareporting/RemarketingList.php
Adding file: vendor/google/apiclient-services/Google/Service/Dfareporting/EventTag.php
Adding file: vendor/google/apiclient-services/Google/Service/Dfareporting/PricingSchedulePricingPeriod.php
Adding file: vendor/google/apiclient-services/Google/Service/Dfareporting/ReportList.php
Adding file: vendor/google/apiclient-services/Google/Service/Dfareporting/DirectorySiteContactsListResponse.php

Installation failed, reverting ./composer.json to its original content.


  [Symfony\Component\Process\Exception\ProcessTimedOutException]              
  The process "vendor/bin/phar-install" exceeded the timeout of 300 seconds.  


require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-auth
oritative] [--] [<packages>]...

✖ 6:14

Due to the fact that phar-install runs composer install --no-dev it roughly doubles the execution time of a normal composer install command.

I tried commenting out the echo line from phar-install but that doesn't help.

I think a proper fix would look like this:

  • Before we do anything, print a message along the lines of "if this command exits early, run this instead: composer xxx --no-hooks && vendor/bin/phar-install" (hopefully we can replace xxx with the actual command that was used)
  • Show a progress bar (or just a throbber bar) while we run composer install --no-dev
  • Show a progress bar while files are added to the PHAR files (count the files, and count as they're added)

This way, the user will not think phar-install has stalled because it's sitting there producing no output, and if the command fails the error message will be on the current screen of text, not 5,000 lines above.

The workaround:

composer require google/apiclient --no-update && composer update --no-scripts && vendor/bin/phar-install

(Require doesn't have a --no-scripts option, so we have to go the circuitous route. This has the side-effect of updating other dependencies unlike a normal require action.)