How to fix “touch(): Utime failed: Operation not permitted” on saving cache with symfony?

后端 未结 2 1926
南笙
南笙 2020-12-22 03:26

I want to caching some response with symfony\\cache. But I\'ve got some error with my cache and sometime with the symfony default cache.

Configuration :

Deb

相关标签:
2条回答
  • 2020-12-22 04:11

    I had the same problem.

    All you need to do is change the type of the synced_folder to nfs, but that option only works with Mac hosts.

    To be able to use it in Windows, you need to install vagrant-winnfsd

    $ vagrant plugin install vagrant-winnfsd

    Then change the type of the synchronisation in your Vagrantfile

    Vagrant.configure("2") do |config|
      config.vm.synced_folder "../project", "/var/www", type: "nfs"
    end
    

    The documentation says that it is also needed to change the type of the network to dhcp, but I didn't need to do that to solve my problem.

    config.vm.network "private_network", type: "dhcp"
    

    I hope this helped

    0 讨论(0)
  • 2020-12-22 04:25

    If you happened to use FAT/FAT32 or another file system with severely limited timestamp range, then that warning is to be expected.

    Symfony's FilesystemCommonTrait::write() method calls touch() function with unix timestamp 0 to force expire cached content. Unix timestamp 0 represents 1970-01-01 date. In FAT file system the allowed timestamp range is 1980-01-01 to 2099-12-31, according Wikipedia. So the touch() function fails and a warning is issued.

    The workaround is to modify the FilesystemCommonTrait::write() method, around line 80.

    Find lines:

    if (null !== $expiresAt) {
        touch($this->tmp, $expiresAt);
    }
    

    Insert before those lines:

    if (0 === $expiresAt) {
        $expiresAt = time() - 1;
    }
    

    This should achieve virtually the same result by instantly expiring the cached content, but without using an invalid file system timestamp.

    Alternatively, change the file system type.

    0 讨论(0)
提交回复
热议问题