Failed to write cache files on install

Hi,

I’m hosting on WPEngine, PHP7 environment.
When attempting installation I can’t get past this error on the first screen when accessing the piwik directory.

Failed to write cache file “/nas/content/live//piwik/tmp/templates_c/e3/e38a4ca8ff5e946c89ff7625f5a9ad63d8c7afe45cc4b2f8b4fb797dd33a1a86.php”.

We’ve checked it server-side, and permissions are ok.
Removed the temp file above and retried.
Tried changing permissions to 777.
Still the same error.

The only thing I can read from the error message is that php can’t write into the tmp folder.

If you have shell access to the server you could try creating a file as www-data (or the user php is running as) and check if an error occurs.

If you don’t I’m running out of ideas as you have already checked the permissions. Maybe contact your hosting provider as 777 permissions should always enable everyone to write.

Ok so we’ve had WPEngine run through a bunch of troubleshooting.

There’s nothing they can find at this point despite messing with permissions and file ownership.
Here’s where we go to in the end:

"I am not seeing what is going on there, when it generates the file, it seems to generate it with the incorrect permissions then instantly gives you: Error in Piwik: Failed to write cache file "/nas/content/live/ … /_analytics/tmp/templates_c/e3/e38a4ca8ff5e946c89ff7625f5a9ad63d8c7afe45cc4b2f8b4fb797dd33a1a86.php

“You may check back with piwik and see if they have any other requirements, I do not see anything server side blocking it, I am not sure what else they would need setup”

If I set the print error backtrace in index.php to TRUE, this is the output.

#0 /nas/content/live/ <SITE> /_analytics/vendor/twig/twig/lib/Twig/Environment.php(448): Twig_Cache_Filesystem->write('/nas/content/li...', '<?php\n\n/* @Inst...')
#1 /nas/content/live/ <SITE> /_analytics/vendor/twig/twig/lib/Twig/Environment.php(362): Twig_Environment->loadTemplate('@Installation/w...')
#2 /nas/content/live/ <SITE> /_analytics/core/View.php(288): Twig_Environment->render('@Installation/w...', Array)
#3 /nas/content/live/ <SITE> /_analytics/core/View.php(272): Piwik\View->renderTwigTemplate()
#4 /nas/content/live/ <SITE> /_analytics/plugins/Installation/View.php(51): Piwik\View->render()
#5 /nas/content/live/ <SITE> /_analytics/plugins/Installation/Controller.php(99): Piwik\Plugins\Installation\View->render()
#6 [internal function]: Piwik\Plugins\Installation\Controller->welcome('The configurati...')
#7 /nas/content/live/ <SITE> /_analytics/core/FrontController.php(544): call_user_func_array(Array, Array)
#8 /nas/content/live/ <SITE> /_analytics/core/FrontController.php(137): Piwik\FrontController->doDispatch('Installation', 'welcome', Array)
#9 /nas/content/live/ <SITE> /_analytics/plugins/Installation/Installation.php(106): Piwik\FrontController->dispatch('Installation', 'welcome', Array)
#10 [internal function]: Piwik\Plugins\Installation\Installation->dispatch(Object(Exception))
#11 /nas/content/live/ <SITE> /_analytics/core/EventDispatcher.php(141): call_user_func_array(Array, Array)
#12 /nas/content/live/ <SITE> /_analytics/core/EventDispatcher.php(180): Piwik\EventDispatcher->postEvent('Config.NoConfig...', Array, false, Array)
#13 /nas/content/live/ <SITE> /_analytics/core/Plugin/Manager.php(843): Piwik\EventDispatcher->postPendingEventsTo(Object(Piwik\Plugins\Installation\Installation))
#14 /nas/content/live/ <SITE> /_analytics/core/Plugin/Manager.php(690): Piwik\Plugin\Manager->reloadActivatedPlugins()
#15 /nas/content/live/ <SITE> /_analytics/core/Plugin/Manager.php(105): Piwik\Plugin\Manager->loadPlugins(Array)
#16 /nas/content/live/ <SITE> /_analytics/core/FrontController.php(271): Piwik\Plugin\Manager->loadActivatedPlugins()
#17 /nas/content/live/ <SITE> /_analytics/core/dispatch.php(33): Piwik\FrontController->init()
#18 /nas/content/live/ <SITE> /_analytics/index.php(27): require_once('/nas/content/li...')
#19 {main}

Ok, completely bizarre resolution to this, but posting anyway in the hope it’ll help someone!

After much troubleshooting server-side, we tried it from another browser in incognito. And…what do you know, no error and the installer worked fine.

So…even though the error messages clearly indicate a server-side permissions issue, it looks like a local problem with temp/cookies etc. Haven’t had a chance to test and confirm.

Found that PHP lost write permission in Windows. Installed permission was set to “Everyone”, needed to add IUSR and it worked again

Thank you for sharing this here! I ran into the same issue and was able to get past it thank to this tip.

So having the following which is similar to your issue
“Error in Matomo: Failed to write cache file "/server/path/tracking/matomo/tmp/templates_c/df/df65558b8bd9793c61bc07977ef0e8c80157ac223f4bca9d2d9b6c8623dfc8b7.php".”

And tried your suggested attempt with incognito mode, can’t login that way. Have a full server with logs so at best i’m shooting for reinstall with existing DB. Which I did try but it still gives the error, just a new filename thats erroring