Jump to content

[SOLVED] Unable to create directory /site/templates/ in wire/core/FileCompiler.php


modifiedcontent
 Share

Recommended Posts

My /assets/cache is messed up after changing PHP to 8 and then back to 7.4 - seems to have something to do with it, apparently had same problem 4 years ago. Manually deleting everything in that folder brings the whole site down with this error:

Quote

Error: Exception: Unable to create directory /site/templates/ (in wire/core/FileCompiler.php line 239)

#0 wire/core/FileCompiler.php (359): FileCompiler->initTargetPath()
#1 wire/core/Wire.php (416): FileCompiler->___compile('/home.php')
#2 wire/core/WireHooks.php (952): Wire->_callMethod('___compile', Array)
#3 wire/core/Wire.php (484): WireHooks->runHooks(Object(FileCompiler), 'compile', Array)
#4 wire/modules/PageRender.module (561): Wire->__call('compile', Array)
#5 wire/core/Wire.php (416): PageRender->___renderPage(Object(HookEvent))
#6 wire/core/WireHooks.php (952)
 

When I upload older cache files - only ones I had saved... - I can restore access, but then I get weird messed up old versions of my pages that I can't get rid of with any cache cleaning methods I know about. 

How can I reset/clear/turn off any caching and compiling etc. to zero/factory settings? I only want template files to get current database content. 

Edit: I guess I had a similar problem 4 years ago, also after changing/messing with PHP version. 

I think I fixed it for now by turning off 'Use Compiled File' in Files in the template settings. Still curious what's going on here, so if anyone has any ideas, please post. 

Link to comment
Share on other sites

I get errors like this that I cannot reproduce more often than I'd like and, because I can't reproduce them, haven't been able to track down how or why they occur. I think it's a race condition based on PHP code running faster than the filesystem (ex: the code says to create a folder, the OS tells PHP OK, code continues, but the filesystem hadn't actually completed creating the folder). When I refresh the same page, I either don't get any errors, or I get a different file/folder that throws an error. Eventually refreshing enough times clears all errors.

This is all just a hunch, so changing PHP versions might cause a large refresh of many files and folders of the cache all at once, which could have a higher probability of hitting a race condition like this - if it is indeed what causes the error.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

@BrendonKoz, when I started this thread I was not sure if PHP had anything to do with it, but looking into it further it became clear that it had. So I started another thread - sorry... - where I found the solution:

PHP upgrade via EasyApache doesn't include the Apache mod_suexec module by default. Without that module 'the system executes PHP applications as the nobody system user' instead of your myusername. 

'If you install the suEXEC module, the system executes PHP applications as the user that owns the VirtualHost that served the request.' I guess these modules were introduced somewhere between recent PHP versions?

Enabling the mod_suexec module, included in EasyApache4, should fix most problems. There is also another Apache module mod_suphp that may be required to fix issues with some scripts.

  • Like 1
Link to comment
Share on other sites

  • modifiedcontent changed the title to [SOLVED] Unable to create directory /site/templates/ in wire/core/FileCompiler.php

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...