All seems well until I get to deploy:vendors, using the default Symfony recipe I get this output
Generating optimized autoload files
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
Exception trace:
() at /var/www/vhosts/deployer_test/releases/20150803094915/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php
:437
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeCommand() at /var/www/vhosts/deployer_test/releases/20150803094915/vendor/sensio/distribu
tion-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:138
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:198
Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:166
Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:91
Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///usr/local/bin/composer/src/Composer/Installer.php:342
Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:131
Composer\Command\InstallCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:874
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:146
Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:82
Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
require() at /usr/local/bin/composer: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]
I can see this is an error, but there is little to suggest what the actual issue is?
Try to run command manually: ... cache:clear --no-warmup and see if it does well.
It works from my regular app. Which is in a different dir. I am just trying to get this deployed elsewhere before making the switch.
I think its an issue to do with the dir I am placing my 'deployed' code into.
If I cd to the dir where I am deploying my code to and run the following commands;
cache:clear --no-warmup
php cache:clear --no-warmup
php app/console cache:clear --no-warmup
They all fail. But I am unsure what prefix, if any, I should be trying with cache:clear --no-warmup.
Thanks for your time and help.
Look like you need to fix it to pass well.
Fix what?
The console works fine for my app, its just not working from inside the deployed code directory.
Ou, hhhh. What kink of ssh impl you use?
Looks like this
server('prod', '1.2.3.4', 22)
->user('root')
->identityFile()
->stage('production')
->env('deploy_path', '/var/www/vhosts/deployer_test');
I found a number of times this was issues with parameters.yml.
Composer, when run through Deployer.org, when deploying a new version with no existing parameters.yml will just get the defaults from parameters.yml.dist, unlike when running manually where it asks you for the parameter values.
If these are not valid for your environment (wrong db user/pass, etc) then composer will fail like this.
Deployer doesn't do well at passing composer's true error message back to the user so it can be a pain (especially on new deployments) when things go wrong on the composer stage. I've found myself always having to start a deployment and then ctrl-c when it gets to installing vendors stage. I then ssh in and run it manually (using the exact composer command deployer does) this usually gives me the true error message and I can fix it pretty quickly.
Case in point, right now I'm deploying a new deployment. I make a habit of never putting DB credentials in the git repo. I always configure parameters.yml on the server itself but generally forget to do it before deploying. Just got
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
On deployment. Went into the folder on the server, ran composer install and got
[Doctrine\DBAL\Exception\DriverException]
An exception occured in driver: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)
So I think some improvements can be made there. Also perhaps an option in symfony recipe that will run composer interactively so that it asks you what it should put in parameters.yml when it creates it.
Wow, thanks a lot for that. But...
If I SSH into my box and then run composer install inside the deployer_test dir from Terminal then I get the following error;
Composer could not find a composer.json file in /var/www/vhosts/the.battle.directory/deployer_test
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
If I cd to release/app and run composer install then I get the same error. Despite composer.json being present inside that dir.
OK I have it running composer install now from within my deployer dir and the error is
Could not open input file: app/console
My console file is in bin, not app, so in my deploy.php file I added
set('bin_dir', 'bin);
But that seems to have made no difference and its still referencing console in app.
This has now morphed into a different and more specific issue.... here https://github.com/deployphp/deployer/issues/425
I know this is closed but I think it still is an issue, @AlexStansfield response was exactly the problem for me.
This will presumably happen to everyone deploying Symfony without their db credentials in the parameters.yml.dist file (which is best practice). Plus like Alex said the issue isn't obvious from Deployer's error output, whereas Composer's is.
@mcwebb since opening this ticket I have used Deployer again on another project and ran into the same issue. The error output needs to be improved in order to fix this, because as you say its best practice to deploy in this manner.
Yeah I would love to have this fixed.
My deployment to new servers now seems to follow this workflow:
Not ideal
You also get another failure because of the need to type YES for the RSA key thing.
I also had the RSA fingerprint accept issue when pulling from a new git server.
And @AlexStansfield current workflow is what I ended up doing too, though I think you could possibly accomplish it through environment variables.
I think at the very least these issues should be documented.
I had the same issue today...
post-install-cmd: Incenteev\ParameterHandler\ScriptHandler::buildParameters
post-install-cmd: Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
post-install-cmd: Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
PHP Fatal error: Cannot use $this as parameter in /var/www/html/wwwdev.za-charts.portal/releases/20160830192302/var/cache/prod/appProdProjectContainer.php on line 4213
.
Exception trace:
() at /var/www/html/wwwdev.za-charts.portal/releases/20160830192302/vendor/sensio/distribution-bundle/Composer/ScriptHandler.php:307
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeCommand() at /var/www/html/wwwdev.za-charts.portal/releases/20160830192302/vendor/sensio/distribution-bundle/Composer/ScriptHandler.ph
p:138
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatche
I managed to get something working by changing the composer parameters by adding
the following line in my deploy.php
// Environment vars
env('composer_options', 'update --verbose --prefer-dist --optimize-autoloader --no-interaction');
Everything runs fine now, I know it's not wise to use 'composer update' but it did the trick
It seems that error of cache:clear --no-warmup
run composer install => event post-install => run all command, function, method in post-install-cmd of your composer.json file => error of cache:clear --no-warmup
I think you should try using composer install with option --no-script
I still have this issue, so it hasn't been fixed. Why was this closed, @jakenoble?!
I fixed the issue I was having but there are many reasons you might get this error. Try running deployed with -vvv to see the real error.
Creating a task to upload the correct database configuration fixed it for me. You can also remove the non-interactive flag from composer on one of the tasks running previously so you get asked for those db credentials.
-vvv is crucial to debug this
Most helpful comment
Case in point, right now I'm deploying a new deployment. I make a habit of never putting DB credentials in the git repo. I always configure parameters.yml on the server itself but generally forget to do it before deploying. Just got
On deployment. Went into the folder on the server, ran composer install and got
So I think some improvements can be made there. Also perhaps an option in symfony recipe that will run composer interactively so that it asks you what it should put in parameters.yml when it creates it.