Finished installing Drupal 8, redirected to the homepage, but the homepage was blank. Looked in apache error.log, and found this:

[Sat Apr 05 14:04:54.858280 2014] [:error] [pid 25720] [client] PHP Fatal error:  Class '__TwigTemplate_7840d7458122591ed21a153648c8459715287fe1203b7d56ae3ec2a4b4bfcb1e' not found in /var/www/core/lib/Drupal/Core/Template/TwigEnvironment.php on line 125, referer:
[Sat Apr 05 14:05:00.369482 2014] [:error] [pid 25014] [client] PHP Fatal error:  Class '__TwigTemplate_7840d7458122591ed21a153648c8459715287fe1203b7d56ae3ec2a4b4bfcb1e' not found in /var/www/core/lib/Drupal/Core/Template/TwigEnvironment.php on line 125
[Sat Apr 05 14:05:05.474080 2014] [:error] [pid 25012] [client] PHP Fatal error:  Class '__TwigTemplate_7840d7458122591ed21a153648c8459715287fe1203b7d56ae3ec2a4b4bfcb1e' not found in /var/www/core/lib/Drupal/Core/Template/TwigEnvironment.php on line 125
[Sat Apr 05 14:05:14.787973 2014] [:error] [pid 24999] [client] PHP Fatal error:  Class '__TwigTemplate_7840d7458122591ed21a153648c8459715287fe1203b7d56ae3ec2a4b4bfcb1e' not found in /var/www/core/lib/Drupal/Core/Template/TwigEnvironment.php on line 125

I replaced client with xx's and referrer with

I have php 5.5.3 running on apache with mysql 5.5.35


mgifford’s picture

You might need to re-install Drupal. It could be that there were leftover pre-compiled files in the sites/default/files directory that are messing things up.

EDIT: Did you install with drush? Something like:

drush @drupal8 si standard -y

kadimi’s picture

@mgifford, me I did it with drush @drupal8 si standard -y like instucted in VDD.

I got the same error with VDD. The funny part is that it worked in another computer, with exact same installation process, the only difference I could find was that if worked on the computer with Vagrant 1.3.5 and didn't in the one with 1.5.1.

mgifford’s picture

That's an odd one for sure... I'll try to let you know if I figure it out.

wylbur’s picture

I got similar errors when I replicated the website instance. When I emptied the files directory, the errors went away.

ekes’s picture

Certainly if deleting files directory solves it. It sounds like when on the command line using drush to install the files directory and contents didn't become read/write for the webserver: because of ownership/permission or SE Linux context.

Michelle’s picture

Title: PHP Fatal Error: Class » PHP Fatal Error: Class __TwigTemplate not found in TwigEnvironment.php

I have this same problem every time I install D8. I use drush si and it will work fine but the site gives me a WSOD until I do a chmod 777 on the sites/default/files directory. This is on Ubuntu 14.04 and PHP 5.5.

(I put a bit more info in the title to make this easier to find)

dysproseum’s picture

For me I needed to update my mount settings because I'm running Drupal inside a Vagrant box. Found here some settings to change the mount permissions:

config.vm.synced_folder "./", "/var/sites/dev.query-auth", id: "vagrant-root",
    owner: "vagrant",
    group: "www-data",
    mount_options: ["dmode=775,fmode=664"]
geerlingguy’s picture

Version: 8.0-alpha10 » 8.0.x-dev

In setting up the Dramble cluster of D8 servers, I was running into the same issue. A while back, it had to do with file permissions issues in the shared GlusterFS mount, but I had resolved that error. After a few hours' debugging, I found that this WSOD and the exact same error can be caused by time drift on multiple servers with a shared mount.

It was the strangest thing, too. If I pointed the load balancer at just one of the servers, everything worked perfectly. If I pointed it at more than one server, then after accessing the second server, the Twig error would start popping up in the logs for all servers, and they'd all WSOD. Then if I pointed the balancer at one server again, that server would load Drupal just fine.

In my case, since I was using Raspberry Pis (without built-in clocks) on a local network, the time from system boot had about +/- 3 seconds of drift, and apparently that was enough to cause this strange error. I even tried having APC on with stat=0, APC on with stat=1, and APC off, and none of those changes made a difference.

Cottser’s picture

Thanks for the report @geerlingguy! Adding a very related (possibly the same) issue, but this may have multiple causes.

opdavies’s picture

@dysproseum's suggestion in #7 to update the mount settings in Vagrantfile seemed to have fixed it for me.

Cottser’s picture

Status: Active » Closed (duplicate)

Now closing as a duplicate of #2429659: Race conditions in the twig template cache. This issue can be re-opened if need be.