Composer install hangs at ScriptHandler::buildBootstrap - php

Sometimes, not every time, but with increasing tendency, i discover the following behaviour with composer install on a symfony project.
We are working with different branches here and after switching from a feature branch back to the master, a composer install is necessary.
Everything works fine, but at the last step, the script terminates after 300 sec while "buildBootstrap".
> post-update-cmd: Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap handling the post-update-cmd event terminated with an exception
[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process "'/usr/bin/php5' '--php-ini=/etc/php5/cli/php.ini' '/var/www/Project/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/../Resources/bin/build_bootstrap
.php' 'app' 'app' " exceeded the timeout of 300 seconds.
Exception trace:
() at phar:///var/www/Project/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php:1219
Symfony\Component\Process\Process->checkTimeout() at phar:///var/www/Project/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php:356
Symfony\Component\Process\Process->wait() at phar:///var/www/Project/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php:210
Symfony\Component\Process\Process->run() at /var/www/Project/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:454
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeBuildBootstrap() at /var/www/Project/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:82
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap() at phar:///var/www/Project/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:211
Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar:///var/www/Project/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:167
Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///var/www/Project/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:92
Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///var/www/Project/composer.phar/src/Composer/Installer.php:346
Composer\Installer->run() at phar:///var/www/Project/composer.phar/src/Composer/Command/UpdateCommand.php:143
Composer\Command\UpdateCommand->execute() at phar:///var/www/Project/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
Symfony\Component\Console\Command\Command->run() at phar:///var/www/Project/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:874
Symfony\Component\Console\Application->doRunCommand() at phar:///var/www/Project/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at phar:///var/www/Project/composer.phar/src/Composer/Console/Application.php:147
Composer\Console\Application->doRun() at phar:///var/www/Project/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at phar:///var/www/Project/composer.phar/src/Composer/Console/Application.php:82
Composer\Console\Application->run() at phar:///var/www/Project/composer.phar/bin/composer:43
require() at /var/www/Project/composer.phar:25
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [packages1] ... [packagesN]
After this error occured once, it is not possible any more to execute composer without hanging directly at the beginning.
$> php -d memory_limit=-1 composer.phar -vvv install
this will hang directly after pressing enter, no output, nothing. I reboot then the machine and maybe the next time is working, and sometimes not like described above.
Has anyone discovered the same thing?

ScriptHandler::buildBootstrap is the very first task at composer which executes code in your symfony project. This means, the php task is waiting for something and there are not so many things which could be in consideration here.
Are you simultaneously debugging with xdebug (mayby with a forgotten debug-session)? Is xdebug running in a debug session and waiting at a break point?
This could be the root cause.

The error you're receiving is stating that the time limit for executing the script has been exceeded. Defining -d memory_limit=-1 will only remove any memory limits. What you should do is to add -d max_execution_time=0 (docs). That should fix your problem.

One fix I found is to disable the xdebug for the CLI. The Composer project mentions this fix and also alias the php keyword and start the xdebug library only when using the php command.
More details here: https://getcomposer.org/doc/articles/troubleshooting.md#xdebug-impact-on-composer

Related

Symfony cache:clear timeout - Exceeded 300 seconds

I'm having an issue with my Symfony 4.3 project and composer. Whenever I try to install, remove, or do anything, it just stops on the "Executing script cache:clear" part and sits there until the timeout hits. I've tried increasing the timeout to something crazy like 2000 and did not help, it would just sit there.
Anyone know how to fix this?
λ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear
[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process ""C:\wamp\bin\php\php7.3.9\php.exe" "--php-ini=C:\wamp\bin\php\php7.3.9\php.ini" "./bin/
console" --ansi cache:clear" exceeded the timeout of 300 seconds.
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
I've tried manually deleting the var/cache contents, but it doesn't help. I have been looking all over the googles for an answer, and stackoverflow.
I found my issue. In my twig.yaml I had the node_modules folder path in there. I forgot to remove it when I was testing a css file and when the cache:clear does the warmup, it literally was going through a 100k of folders and files. Which explains why 300 seconds isn't enough time, and even if I had it set to 2000 seconds I bet it still would have ran out of time.
Lesson Learn: Be careful of your twig configurations!!!
I hope that this can be help, try in this way
composer install --prefer-dist --no-scripts -vvv

Laravel 5.2 Script php artisan clear-compiled handling the pre-update-cmd event returned with an error

I am trying to push my project to live server from local machine, where it is running fine.
But when i pushed code to production machine and run following command:
composer update
it is showing me following error:
> > php artisan clear-compiled
>
> [BadMethodCallException] Method after does not exist.
>
>
> Script php artisan clear-compiled handling the pre-update-cmd event
> returned with an error
>
> [RuntimeException] Error Output:
>
>
> update [--prefer-source] [--prefer-dist] [--dry-run] [--dev]
> [--no-dev] [--lock] [--no-plugins] [--no-custom-installers]
> [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies]
> [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
> [-a|--classmap-authoritative] [--ignore-platform-reqs]
> [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs]
> [--] [<packages>]...
Please help! thanks
Only running
composer update
won't help...
Try following the complete procedure here
On the Production Server you should run only composer install! This should avoid your error. With update you install the newest configured version of each package required in your composer.json. With install you install the exact same version you used on your local server (stored in your composer.lock file).
Well, it's your php artisan clear-compiled command that is failing here. Most likely, the problem comes from when your application is booting. Somewhere, there is a call to the method after in your application, a method which does not exist. Please note that that call does not have be (and is indeed not) in the ClearCompiledCommand, but anywhere in your code.

composer update fails with "...target machine actively refuses connection..."

I'm trying to do a simple composer action (install laravel), and getting stopped at the gates.
The complete error message is
C:\.....\Composer>composer install
Loading composer repositories with package information
[Composer\Downloader\TransportException]
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: No connection could be made because the target machine actively refused it.
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress
] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...
C:\.....\Composer>
Win7 / PHP5.5.8
I'm using Chrome and IE, both use the same automatic configuration script (pointing to a "wpad.dat" file).
I've tried the following:
PHP Variables in a diagnostic (php -i)
Variable => Value
...
_SERVER["https_proxy"] => http://172.26.3.10:8080
_SERVER["http_proxy"] => http://172.26.3.10:8080
What am I missing? I've been following all sorts of threads, but I seem to be missing something pretty basic.
pinging the proxy server produces a response from the same ip address as above.
Put https://getcomposer.org/installer into the browser, and I get a file called installer downloaded (on Chrome).
Composer is not getting installed windows 7
How to enable PHP's openssl extension to install Composer?
verbose diagnostics
`C:\xampp\htdocs>composer -v global require "laravel/installer"
Changed current directory to C:/Users/.../AppData/Roaming/Composer
[Composer\Downloader\TransportException]
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: No connection could be made because the target machine actively refused it.
Exception trace:
() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Util/RemoteFilesystem.php:297
Composer\Util\RemoteFilesystem->get() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Util/RemoteFilesystem.php:84
Composer\Util\RemoteFilesystem->getContents() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Repository/ComposerRepository.php:601
Composer\Repository\ComposerRepository->fetchFile() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Repository/ComposerRepository.php:415
Composer\Repository\ComposerRepository->loadRootServerFile() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Repository/ComposerRepository.php:246
Composer\Repository\ComposerRepository->hasProviders() at phar://C:/xampp/htdocs/composer.phar/src/Composer/DependencyResolver/Pool.php:99
Composer\DependencyResolver\Pool->addRepository() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Command/InitCommand.php:565
Composer\Command\InitCommand->getPool() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Command/InitCommand.php:601
Composer\Command\InitCommand->findBestVersionForPackage() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Command/InitCommand.php:334
Composer\Command\InitCommand->determineRequirements() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Command/RequireCommand.php:107
Composer\Command\RequireCommand->execute() at phar://C:/xampp/htdocs/composer.phar/vendor/symfony/console/Command/Command.php:256
Symfony\Component\Console\Command\Command->run() at phar://C:/xampp/htdocs/composer.phar/vendor/symfony/console/Application.php:838
Symfony\Component\Console\Application->doRunCommand() at phar://C:/xampp/htdocs/composer.phar/vendor/symfony/console/Application.php:189
Symfony\Component\Console\Application->doRun() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Console/Application.php:147
Composer\Console\Application->doRun() at phar://C:/xampp/htdocs/composer.phar/vendor/symfony/console/Application.php:120
Symfony\Component\Console\Application->run() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Console/Application.php:82
Composer\Console\Application->run() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Command/GlobalCommand.php:80
Composer\Command\GlobalCommand->run() at phar://C:/xampp/htdocs/composer.phar/vendor/symfony/console/Application.php:838
Symfony\Component\Console\Application->doRunCommand() at phar://C:/xampp/htdocs/composer.phar/vendor/symfony/console/Application.php:189
Symfony\Component\Console\Application->doRun() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Console/Application.php:147
Composer\Console\Application->doRun() at phar://C:/xampp/htdocs/composer.phar/vendor/symfony/console/Application.php:120
Symfony\Component\Console\Application->run() at phar://C:/xampp/htdocs/composer.phar/src/Composer/Console/Application.php:82
Composer\Console\Application->run() at phar://C:/xampp/htdocs/composer.phar/bin/composer:43
require() at C:\xampp\htdocs\composer.phar:24`
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort
packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...
C:\xampp\htdocs>
I'd start with enabling verbose output of composer, like
composer -v install
might shed some light, though not guaranteed

Composer returning mysterious error

Unfortunately, I do not know exactly what I did that caused this error to begin showing up whenever I run
composer update
from the command line. I believe it happened after adding laracasts/integrated to my composer.json, but have a hard time believing that's the issue. I did try removing laracasts/integrated and the problem remained. Here's the exact error I get:
$ composer update
> php artisan clear-compiled
[ErrorException]
Undefined index: REQUEST_URI
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
[RuntimeException]
Error Output:
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--] [<packages>]...
After googling around, it appeared that perhaps deleting the composer.lock file and running
composer install
might fix the problem, but that did not work for me. I found a myriad of similar questions, but none that fit the exact error I was getting, so I was hoping someone with a lot of familiarity with these types of errors can help me debug it.
From what I can tell,
php artisan clear-compiled
is causing this error, but again, I'm really unfamiliar with how to go about debugging this type of problem.
Thanks.
Artisan boots a command line equivalent of the HTTP version of the app. Based on this error, you likely have a service provider (or some other bootable class) attempting to access the $_SERVER array, which is obviously not going to have a REQUEST_URI when run through command line.
Check your providers. If that doesn't light up the answer, search/grep for REQUEST_URI to find out which class is trying to use it.
I also had a similar error. (see below)
Writing lock file
Generating autoload files
> php artisan clear-compiled
[ErrorException]
Undefined index: HTTP_HOST
Script php artisan clear-compiled handling the post-update-cmd event returned with error code 1
I did grep the whole source and finally got the cause of the error.
I need to use the safer method than the method of PHP.
source
/app/Http/routes.php
diff
(before) $_SERVER['HTTP_HOST']
(after) Request::server('HTTP_HOST')

Composer commands generate error on Windows 8 and Laravel 4

I am trying to run the command composer install from the command line and every time I do so I generate the following error:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me
ssage":"main(): Failed opening required '..\/app\/controllers\/UsersController.p
hp' (include_path='C:\\xampp\\htdocs\\project\\html\\vendor\/phpseclib\/phpsecli
b\/phpseclib;.;C:\\xampp\\php\\PEAR')","file":"C:\\xampp\\htdocs\\project\\html\
\app\\filters.php","line":2}}Script php artisan clear-compiled handling the post
-install-cmd event returned with an error
[RuntimeException]
Error Output:
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-p
lugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress
] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [pac
kages1] ... [packagesN]
I also get the exact same error when running:
composer update
I am on Windows 8, using XAMPP, the PHP version is 5.5, and I am using Laravel 4. It is also worth noting that I copied this project from a Git repository and not create a project from scratch.
And I get the following response when trying to run the command php composer.phar update
Could not open input file: composer.phar
Thank you in advance! I am new to Laravel so feel free to spell things out for me, I might need it.

Categories