Symfony2 post-update-cmd gives "An error occurred when generating the bootstrap file" Symfony2 post-update-cmd gives "An error occurred when generating the bootstrap file" symfony symfony

Symfony2 post-update-cmd gives "An error occurred when generating the bootstrap file"


How to solve install/update Symfony 2 issues

One important Symfony requirement is that the app/cache and app/logs directories must be writable both by the web server and the command line user.

On Linux and macOS systems, if your web server user is different from your command line user, you need to configure permissions properly to avoid issues. There are several ways to achieve that:

The most common solution :

In a terminal execute following commands :

rm -rf binrm -rf vendorcomposer install# or if your didn't install composerphp composer.phar install

It should work now! For more informations see Symfony installation.

If you still have this error : «An error occurred when generating the bootstrap file»
It means that you have file permission issue.
See below procedure for solve the problem ↓

Setting up or Fixing File Permissions :

In a terminal execute following commands :

rm -rf app/cache/*rm -rf app/logs/*

On macOS systems, the chmod command supports the +a flag to define an ACL. Use the following script to determine your web server user and grant the needed permissions:

HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1)sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logssudo chmod +a "$(whoami) allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs

On most Linux and BSD distributions don't support chmod +a, but do support another utility called setfacl. You may need to install setfacl and enable ACL support on your disk partition before using it. Then, use the following script to determine your web server user and grant the needed permissions:

HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1)# if this doesn't work, try adding `-n` optionsudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX app/cache app/logssudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX app/cache app/logs

If none of the previous methods work for you

Change the umask so that the cache and log directories are group-writable or world-writable (depending if the web server user and the command line user are in the same group or not). To achieve this, put the following line at the beginning of the app/console, web/app.php and web/app_dev.php files:

umask(0002); // This will let the permissions be 0775// orumask(0000); // This will let the permissions be 0777

Note : Changing the umask is not thread-safe, so the ACL methods are recommended when they are available.

For more information see official documentation : Symfony file permissions


I think remove the folder bundles in the web directory "web/bundles" before running the update. This should solve the assets install problems in post-update-cmd


I had the same problem and solved it in two parts. The crux of the problem was bad code on my part that wouldn't specifically apply to someone else, but my method for uncovering the issue might be useful to someone else.

First, I created a temporary file: app/test.php

use Doctrine\Common\Annotations\AnnotationRegistry;use Composer\Autoload\ClassLoader;error_reporting(E_ALL | E_STRICT);ini_set('display_errors', 1);/** * @var ClassLoader $loader */$loader = require __DIR__.'/../vendor/autoload.php';

You'll notice that is a slimmed down version of app/autoload.php

Next in my shell, I simply ran:

php app/test.php

After some trial and error, I discovered that I had an error in a private repo that I had as a requirement in my composer.json file. In my case, and I had a bootstrap file that was calling the very bootstrap.cache.php that we're trying to get composer to create.

Anyway, this method was useful because it output errors that composer install/update would not, even with "--verbose" enabled and temporarily modifying the code to output all errors.