开发者

CakePHP 2.0 - Cake was unable to write to File cache

I'm using CakePHP 2.0 RC-1. After checking out the project from SVN, the application is starting to complain that it can't write cache files to the tmp/cache directory. Since this is local, I know the directory is writeable and I can CLEARLY see that the directories are even filled with files, so the error开发者_如何学运维 is a bit strange.

Here are some of the errors I've encountered:

_cake_core_ cache was unable to write 'cake_dev_nb' to File cache

fopen(c:\cake\app\tmp\cache\models\cake_model_default_media) [function.fopen]: failed to open stream: No error [CORE\Cake\Cache\Engine\FileEngine.php, line 127]

No error?! Wth?

Now, if I look in the FileEngine file, at line 127 it reads:

if (!$handle = fopen($this->_File->getPathName(), 'c')) {
            return false;
}

By replacing the "c" with "w", no error is encountered and everything works as it should. But, it should not be necessary to modify the core Cake libraries to work around this problem. Let me repeat that on my other computer this works as intended, without editing the core library. Both use the Windows OS and the read/write rights to the tmp/cache-folder is exactly the same.

Edit: Here's a site that experiences the error outputs I'm having locally

Example site found by Googling. Not my site: http://www.12h30.net/credit/

Any suggestions?

Update: Here is why: This is caused if you have a PHP-version that's too low, before 5.2.6, as outlined by "api55" in the comments. Thanks for the reply. Hope this helps you too.


Well, in my case, when I checked my app, it hadn't the /tmp folder. Then I created the structure (/tmp/cache/models, /tmp/cache/persistent) and all worked well. This happened to me maybe git ignore empty folders, so they weren't created.


I had a similar problem, it was because I had chown -R www to the app/tmp directory to get Cake to run "properly" without giving everyone write privileges. Looks like during development the only way to use the console and the web is to give everyone write privileges, or add yourself to the www group perhaps.

Easy solution:

chmod -R 777 app/tmp

or

chown -R username app/tmp

while using the console and

chown -R www app/tmp

when using the web


Just give the right CHMOD (776 works fine for me) to app/tmp


for windows users with the same error/warning: make sure you run the command prompt in elevated mode ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜