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"
Related
I have a Laravel/Homestead project that is finally working locally. Now I'm trying to port it over to HostGator and can't get it running due to titled error. I've tried all the suggested solutions to no avail. Including:
composer require laravel/laravel
composer dump-autoload
composer install --no-scripts
composer update
composer update --no-scripts
Nothing works. Same error. If this is a clue, I also tried
php artisan clear-compiled
and get response of
Could not open input file: artisan
I'm about ready to give up on Laravel/Homestead. I've spent countless hours on this framework with nothing but problems to show for it. Would not recommend it to anybody.
You can see the error yourself here:
http://www.tekknow.net/MedAverter/medaverter/
Any suggestions before I throw in the towel?
For the artisan file, the artisan file is not required through includes, you have it in your root project, which is created when you create your Laravel project. Here is the file.
So you need to have that file in your project.
For the missing class, you try to require laravel/laravel but that is not the correct dependency. Again that github repo is a shell for a project, to have Laravel features you need to base of laravel/laravel and include laravel/framework.
Hope this clears up some confusing and can get you on the right track. Secondly you shouldn't port it over, but simply cloning your project and running composer install should be sufficient.
The problem turned out to be two issues.
1. The wrong version of PHP was running. If I ssh'ed into the hostgator server and did
php -v
It showed PHP 5.6.30 even though I had selected Php 7.1 in the cPanel PHP Selector. If I did
tekknow.net/phpinfo.php
it would say I was using 7.1. Called up HostGator tech support and they were able to change it to PHP 7.3.13.
Now if I do:
php artisan clear cache
I no longer get the error about
Parse error: syntax error, unexpected '?' in
/home1/sl1k7f3j/public_html/medaverter/bootstrap/app.php on line 15
which was an error caused by a version of php that doesn't support the ?? operator.
The second problem was a lack of memory issue. If I did
composer update
It would start to work but would fail in about 30 seconds with
Fatal error: Out of memory (allocated 709623808) (tried to allocate
34187559 bytes) in
phar:///opt/cpanel/composer/bin/composer/src/Composer/Json/JsonFile.php
on line 270
The HostGator tech rep could not figure out why that was happening but I got around that issue by manually uploading my local vendor folder to the host server.
Now when I go to http://tekknow.net/medaverter/ it works!
I am using Symfony 4...
I run this command:
php -d memory_limit=-1 composer.phar require form
The script runs successfully through these points...
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package symfony/lts is abandoned, you should avoid using it. Use symfony/flex instead.
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!!
!! // Clearing the cache for the dev environment with debug
!! // true
Then I get this error:
!! Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Applications/XAMPP/xamppfiles/htdocs/xxxx/vendor/symfony/var-dumper/Cloner/Data.php on line 306
I can run this script without issue:
php -d memory_limit=-1 bin/console cache:clear
I do not know how to get around this because my command is saying to bypass memory limit. What can I do to get beyond this error, I cannot get anything installed at this point.
When Composer executes script it's a separate PHP call by Composer, so your command line directive doesn't apply to it.
The typical solution would be to configure PHP via its configuration file, so that all instances are affected.
If you don't have access to change PHP configuration your best option is probably to run composer with --no-scripts and then try to run necessary scripts individually with memory limit option.
Setting the memory limit for the whole php process might be dangerous, as this could lead to memory problems when executing PHP in a web context. So be sure to only update the configuration for CLI. Composer also provides a configuration point via environment variable COMPOSER_MEMORY_LIMIT You can either set it via export COMPOSER_MEMORY_LIMIT=-1 add it to your .bashrc if you always want to enable it or just prepend the command itself if you only need it once during installation:
COMPOSER_MEMORY_LIMIT=-1 composer require form
You can find all the different ways of getting around memory limit-related problems in Composer's Troubleshooting Guide as well.
As a pre-cursor to my issue, I have very little SSH or comandline experience so may possibly be maiking a glaring mistake but dont realise it..
I'm trying to install OroCommerce on my shared cloud hosting and have been following the instructions within the readme file produced by Oro but when it comes to installing composer I get the following error:
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Composer could not find a composer.json file in /var/sites/mydomain.com
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Fistly the warning regarding CLI... I've read through a post on here regarding the use of php -cli composer.phar install but this makes no difference and the error message is the same.
I've read through the composer guide on creating a composer.json file but as the file exists in the orocommerce-application folder I'm not sure that creating one is the issue here, perhaps more that I've done something wrong preventing composer from accesisng the file?
I've tried moving the composer.json file from it's folder into the domain's root and whilst that does start installation I then get the following error:
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Loading composer repositories with package information
Updating dependencies (including require-dev)
<br />
<b>Fatal error</b>: Maximum execution time of 30 seconds exceeded in <b>phar:///var/sites/mydomain.com/composer.phar/src/Composer/Package/Package.php</b> on line <b>109</b><br />
Any help would be greatly appreciated.
Please make sure you are running php composer install in the same directory where you uploaded/cloned OroCommerce code.
And check your hosting provider documentation (or contact their support) on how to run php from command line, most likely you would have to use a different executable file (-cli flag is not what you need).
I had the same issue, you need to extend the maximum execution time in your php.ini file, for instance :
ini_set('max_execution_time', 360); // 360 seconds for 6 minutes
Firstly you have to do
php composer install --prefer-dist
This will install all the required/dependent bundles and libraries
then do
php app/console oro:install --env=dev --timeout=99999 --debug=true
php app/console cache:clear --env=dev
for development purpose, or
php app/console oro:install --env=prod --timeout=99999 --debug=true
php app/console cache:clear --env=prod
for production/live purpose
NOTE: --timeout will replace your default timeout in php.ini. It worked for me by extending the timeout.
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')
When trying to clear the cache on my symfony2 project, I am getting this error message:
PHP Fatal error: Call to undefined method Symfony\Component\Console\Output\ConsoleOutput::isVerbose() in /var/staging_www/www.sciforum.net/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php on line 87
Any idea? Thank you.
EDIT:
When trying to update vendors, I am getting this error message:
Clearing the cache for the dev environment with debug true
PHP Fatal error: Call to undefined method Symfony\Component\Console\Output\ConsoleOutput::isVerbose() in /var/staging_www/www.sciforum.net/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php on line 99
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
Check your versions in composer.json (and double-check versions for Symfony-based libraries in composer.lock). isVerbose only became available in ConsoleOutput with version 2.4.
You may have some mixed versions of the Symfony libraries.
You can fixit if you delete the directories first:
sudo rm -rf app/logs
sudo rm -rf app/cache
I've had a similar problem. Disabling PHP opcache for CLI helped me.
Disable it in php.ini:
opcache.enable_cli=0
Save the file and try clearing the cache again.