Unable To Write To Cache.php or FileEngine.php

This is an error I commonly encounter when working on incremental builds on CakePHP via GitHub.

Warning: _cake_core_ cache was unable to write ‘cake_dev_en-us’ to File cache in/Applications/MAMP/htdocs/review/lib/Cake/Cache/Cache.php on line 310

Warning: /Applications/MAMP/htdocs/review/app/tmp/cache/persistent/ is not writable in/Applications/MAMP/htdocs/review/lib/Cake/Cache/Engine/FileEngine.php on line 337

Fatal error: Uncaught exception ‘CacheException’ with message ‘Cache engine _cake_core_ is not properly configured.’ in /Applications/MAMP/htdocs/review/lib/Cake/Cache/Cache.php:166 Stack trace: #0 /Applications/MAMP/htdocs/review/lib/Cake/Cache/Cache.php(136): Cache::_buildEngine(‘_cake_core_’) #1 /Applications/MAMP/htdocs/review/app/Config/core.php(336): Cache::config(‘_cake_core_’, Array) #2 /Applications/MAMP/htdocs/review/lib/Cake/Core/Configure.php(77): include(‘/Applications/M…’) #3 /Applications/MAMP/htdocs/review/lib/Cake/bootstrap.php(170): Configure::bootstrap(true) #4 /Applications/MAMP/htdocs/review/app/webroot/index.php(91): include(‘/Applications/M…’) #5 {main} thrown in/Applications/MAMP/htdocs/review/lib/Cake/Cache/Cache.php on line 166

This error can be because of two reasons, permissions of the below files or missing tmp folder.

Ensure that the folder and its contents of /CakePHP/lib/ (in my example is /reivew/lib/) has sufficient permissions, 755. Remember to propagate the permissions to sub folders and files.

If they still doesn’t fix it. Check if you have a “tmp” folder in /CakePHP/app/. If it is missing, copy the tmp file from your previous CakePHP build to the current build.

Fin.

Advertisements

4 thoughts on “Unable To Write To Cache.php or FileEngine.php

    • Hi Kunal,

      the other solution I’ve tried is to make a new CakePHP setup (remember to setup the database and config files and change the security and salt values. Copy the contents of the old folder to the new folder. Depending on the extent of your development, the three most important folders (IMO) to copy are Controller, Model and View.

      If you use PHPUnit testing, then copy the Test folder.
      If you have modified the CSS, add custom CSS or JS, etc. copy the Webroot folder.

      Then open your browser and access the new folder (http://localhost/new/)
      If everything loads smoothly, you can rename or move the “new” folder to wherever your previous “old” folder was located.

      Depending on what computer you use, I personally use a Mac, so be careful when copying folders, some OS systems do not copy the hidden files. Either unhide hidden files and copy them or use a FTP client (like Filezilla) to copy the folders / files within your system.

      Cheers,
      fukie

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s