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')
Related
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
I'm working on a project with Laravel 5.1 and tried to implement facebook api. Since I used:
composer require facebook/php-sdk-v4
I'm having an error in ResetsPasswords.php on every page:
FatalErrorException in ResetsPasswords.php line 21: syntax error, unexpected '}'
ResetsPasswords.php was working fine and is not having any errors at all. Line 18-21:
public function getEmail()
{
return view('auth.password')
}
I tried to remove the Facebook package. Now it's telling me the following information in cmd:
Warning: This development build of composer is over 60 days old. It is recommended to update it by running "C:\ProgramData\ComposerSetup\bin\composer.phar self-update" to get the latest version.
> php artisan clear-compiled
[Symfony\Component\Debug\Exception\FatalErrorException] syntax error, unexpected '}'
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
[RuntimeException]
Error Output:
remove [--dev] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...
I guess it have something to due with my composer version. But I'm not very experienced with composer and before I really make a mess of it, I think it's not unwise to ask for some help.
So I really appreciate your help, as I cannot work on the project untill this problem is solved.
you forget ; :
return view('auth.password');
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
I have a very weird issue since yesterday.
Running composer install on my production server causes this error... Keep in mind I do not get any error on my local server (Homestead VM).
Nothing to install or update
Writing lock file
Generating autoload files
Executing command (CWD): php artisan clear-compiled
Executing command (CWD): php artisan optimize
Generating optimized class loader
Compiling common classes
Script php artisan optimize handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output:
Exception trace:
() at phar:///home/site/public_html/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:177
Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///home/site/public_html/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:91
Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///home/site/public_html/composer.phar/src/Composer/Installer.php:342
Composer\Installer->run() at phar:///home/site/public_html/composer.phar/src/Composer/Command/InstallCommand.php:131
Composer\Command\InstallCommand->execute() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
Symfony\Component\Console\Command\Command->run() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:874
Symfony\Component\Console\Application->doRunCommand() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at phar:///home/site/public_html/composer.phar/src/Composer/Console/Application.php:146
Composer\Console\Application->doRun() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at phar:///home/site/public_html/composer.phar/src/Composer/Console/Application.php:83
Composer\Console\Application->run() at phar:///home/site/public_html/composer.phar/bin/composer:43
require() at /home/site/public_html/composer.phar:25
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] [--ignore-platform-reqs] [packages1] ... [packagesN]
So it seems the error appears in the post-install-cmd when php artisan optimize is set to run... The weird thing is that when I run all the post-install-cmd manually, I DO NOT get any error.
So I tried :
doing a composer selfupdate
Removing composer and re-installing it
Using composer.phar instead of the global one
doing composer dumpautoload
removing the composer.lock file
removing all cache composer clearcache
running a composer update, on production (desperate)
And still get the same error. Do you have any ideas ? I'm running out of keywords to find similar issues online.
Thanks a lot
EDIT :
Also failed to mentioned that the site is working fine.. No error when browsing.
EDIT 2 :
As per #marcanuy suggestion, I tried removing the vendor directory. While at it I also cleared compiled and composer cache. Composer re-downloaded/installed everything. And still get the same error.
EDIT 3 :
So I narrowed it down to this. I DO NOT GET THE ERROR IF I SET APP_DEBUG to true... When false, I get the error. Any idea why ?
FINAL EDIT :
Thanks to Ben Johnson who pointed me in the right direction... I checked my raw PHP logs, and yes they differ from the laravel logs (duh, should have thought of that). I saw a weird memory error in there, not related to the files in the error stack above :
[02-Jun-2015 14:05:01 Europe/Paris] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 64 bytes) in /vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 169
After the tada moment. I raised memory_limit and composer install ran without error, and with APP_DEBUG turned OFF.
Thanks a lot to everyone for your help.
Have you examined the raw PHP logs?
It is crucial to note that Laravel's logs do not contain all of the same information that PHP's raw error logs do. When using Laravel, always check the raw PHP logs when an error occurs and the visible output and Laravel log do not reveal the root cause.
It is equally crucial to note that Composer is subject to the whims of any PHP file that it loads and processes, which means that any type of error that might occur in a PHP file that is completely unrelated to Composer is capable of causing Composer to fail, oftentimes without explanation. However, the root cause is almost always apparent in the raw PHP logs.
The empty method signature at the top of your stack-trace is unusual. I suspect that if you check the raw PHP logs, you will find some unusual condition present that fully explains the sudden termination of composer.phar.
Please check there next and let us know what you find.
The problem is related to php artisan optimize and not the composor.phar as you can see in the Optimizing the Framework for Better Performance if APP_DEBUG is true you need to use --force option with the command. So to solve this error you need to change your composor.json line in "post-install-cmd" section from "php artisan optimize" to "php artisan optimize --force"
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.