HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

2021.009 - Fatal Error in Twig\Loader\FilesystemLoader.findTemplate();

I get this message when opening home page after copying all files across (am upgrading from 3.2):

Unable to find template "C:/inetpub/vhosts/mickhynes.com/forum.dartman.online/library/Vanilla/Web/Asset/AssetPreloadModel.twig" (looked into: C:\Inetpub\vhosts\mickhynes.com\forum.dartman.online).

The error occurred on or near: C:\inetpub\vhosts\mickhynes.com\forum.dartman.online\vendor\twig\twig\src\Loader\FilesystemLoader.php

246:         if (!$throw) {
247:             return false;
248:         }
250:         throw new LoaderError($this->errorCache[$name]);
251:     }
253:     private function normalizeName($name)
254:     {

Additional information for support personnel:

  • Application: Vanilla
  • Application Version: 2021.009
  • PHP Version: 7.4.27
  • Operating System: WINNT
  • Server Software: Microsoft-IIS/10.0
  • User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
  • Request Uri: /
  • Controller: Twig\Loader\FilesystemLoader
  • Method: findTemplate

Can anyone help please?



  • R_JR_J Ex-Fanboy Munich Admin

    If you try to run this on Windows with IIS, you need to know IIS good enough to help yourself. There are not many discussions dealing with that topic here and I do not know if they are helpful

  • Thanks. I feel someone may be able to help. The file specified is in the location specified, and the IIS app pool has full access to that folder.

  • hynseyhynsey New
    edited March 2022

    I've managed to fix this. To anyone else running it on Windows, it seems to be how paths are being presented. I can't vouch for long-term viability of this solution, but it fixed my situation. In the findTemplate function in the /vendor/twig/twig/src/Loader/Filesystemloader.php file, I commented out the lines below and replaced with new ones (essentially just use $shortname instead of combining it with $path). $shortname contained the full path to the file already in some (but not all) cases - so the function now handles both.

    foreach ($this->paths[$namespace] as $path) {
                if (!$this->isAbsolutePath($path)) {
                    $path = $this->rootPath.$path;							
                //if (is_file($path.'/'.$shortname)) {
    	if (is_file($shortname)) {  // <---- check file on $shortname only
                    //if (false !== $realpath = realpath($path.'/'.$shortname)) {
    		if (false !== $realpath = realpath($shortname)) { // <---- use $shortname only
                        return $this->cache[$name] = $realpath;
                    return $this->cache[$name] = $shortname; // <---- use $shortname only
    	if (is_file($path.'/'.$shortname)) { // <---- check file combining $path and $shortname - original implementation
                    if (false !== $realpath = realpath($path.'/'.$shortname)) {				
                        return $this->cache[$name] = $realpath;
                    return $this->cache[$name] = $path.'/'.$shortname;
Sign In or Register to comment.